wpcom-editor-colors.php 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  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:not(.is-style-outline) .wp-block-button__link,
  20. #editor .editor-styles-wrapper .wp-block-button:not(.is-style-outline) .wp-block-button__link.has-focus,
  21. #editor .editor-styles-wrapper .wp-block-button:not(.is-style-outline) .wp-block-button__link:focus,
  22. #editor .editor-styles-wrapper .wp-block-button:not(.is-style-outline) .wp-block-button__link:hover,
  23. #editor .editor-styles-wrapper .wp-block-media-text,
  24. #editor .editor-styles-wrapper .wp-block-pullquote.is-style-solid-color', 'color' ),
  25. /**
  26. * Utility Classes
  27. */
  28. // Text-color
  29. array( '#editor .editor-styles-wrapper .has-primary-background-color[class],
  30. #editor .editor-styles-wrapper .has-secondary-background-color[class],
  31. #editor .editor-styles-wrapper .has-foreground-background-color[class],
  32. #editor .editor-styles-wrapper .has-foreground-dark-background-color[class],
  33. #editor .editor-styles-wrapper .has-foreground-light-background-color[class],
  34. #editor .editor-styles-wrapper .has-background-color[class]', 'color' ),
  35. // Background-color
  36. array( '#editor .editor-styles-wrapper .has-background-background-color[class]', 'background-color' ),
  37. // Text-color darkened
  38. array( '#editor .editor-styles-wrapper .has-background-dark-color[class]', 'color', '-1' ),
  39. // Background-color darkened
  40. array( '#editor .editor-styles-wrapper .has-background-dark-background-color[class]', 'background-color', '-1' ),
  41. // Text-color lightened
  42. array( '#editor .editor-styles-wrapper .has-background-light-color[class]', 'color', '+1' ),
  43. // Background-color lightened
  44. array( '#editor .editor-styles-wrapper .has-background-light-background-color[class]', 'background-color', '+1' ),
  45. /**
  46. * Grays
  47. * Uses a slightly darker color
  48. */
  49. // Color
  50. array( '#editor .editor-styles-wrapper .wp-block-separator.is-style-dots', 'color', '-1' ),
  51. // Border-color
  52. array( '#editor .editor-styles-wrapper .wp-block-code', 'border-color', '-1' ),
  53. // Border-top-color
  54. array( '#editor .editor-styles-wrapper .wp-block-pullquote', 'border-top-color', '-1' ),
  55. // Border-bottom-color
  56. array( '#editor .editor-styles-wrapper .wp-block-pullquote,
  57. #editor .editor-styles-wrapper .wp-block-separator', 'border-bottom-color', '-1' ),
  58. ), __( 'Background Color' ) );
  59. // Link Color
  60. // $config-global--color-primary-default
  61. add_editor_color_rule( 'link', '#0073AA', array(
  62. // Background-color
  63. array( '#editor .editor-styles-wrapper .button,
  64. #editor .editor-styles-wrapper .wp-block-a8c-blog-posts + .button,
  65. #editor .editor-styles-wrapper .wp-block-button:not(.is-style-outline) .wp-block-button__link:not(.has-background-color),
  66. #editor .editor-styles-wrapper .wp-block-button:not(.is-style-outline) .wp-block-button__link:not(.has-background),
  67. #editor .editor-styles-wrapper .wp-block-pullquote.is-style-solid-color', 'background-color' ),
  68. // Text-color
  69. array( '#editor .editor-styles-wrapper .wp-block-a8c-blog-posts .entry-title a,
  70. #editor .editor-styles-wrapper .wp-block-button.is-style-outline .wp-block-button__link:not(.has-text-color),
  71. #editor .editor-styles-wrapper a', 'color' ),
  72. // Border color left
  73. array( '#editor .editor-styles-wrapper .wp-block-quote', 'border-left-color' ),
  74. // Border color right
  75. array( '#editor .editor-styles-wrapper .wp-block-quote[style*="text-align: right"],
  76. #editor .editor-styles-wrapper .wp-block-quote[style*="text-align:right"]', 'border-right-color' ),
  77. /**
  78. * Utility Classes
  79. */
  80. // Background-color
  81. array( '#editor .editor-styles-wrapper .has-primary-background-color[class]', 'background-color' ),
  82. // Text-color
  83. array( '#editor .editor-styles-wrapper .has-primary-color[class]', 'color' ),
  84. ), __( 'Link Color' ) );
  85. // Text Color
  86. // $config-global--color-foreground-default
  87. add_editor_color_rule( 'txt', '#1e1e1e', array(
  88. // Text-color
  89. array( '#editor .editor-styles-wrapper .editor-post-title__block .editor-post-title__input,
  90. #editor .editor-styles-wrapper .wp-block-pullquote,
  91. #editor .editor-styles-wrapper', 'color' ),
  92. /**
  93. * Utility Classes
  94. */
  95. // Text-color
  96. array( '#editor .editor-styles-wrapper .has-background-background-color[class],
  97. #editor .editor-styles-wrapper .has-background-dark-background-color[class],
  98. #editor .editor-styles-wrapper .has-background-light-background-color[class],
  99. #editor .editor-styles-wrapper .has-foreground-color[class]', 'color' ),
  100. // Background-color
  101. array( '#editor .editor-styles-wrapper .has-foreground-background-color[class]', 'background-color' ),
  102. // Text-color darkened
  103. array( '#editor .editor-styles-wrapper .has-foreground-dark-color[class]', 'color', '-1' ),
  104. // Background-color darkened
  105. array( '#editor .editor-styles-wrapper .has-foreground-dark-background-color[class]', 'background-color', '-1' ),
  106. // Text-color brightened
  107. array( '#editor .editor-styles-wrapper .has-foreground-light-color[class]', 'color', '+2' ),
  108. // Background-color brightened
  109. array( '#editor .editor-styles-wrapper .has-foreground-light-background-color[class]', 'background-color', '+2' ),
  110. /**
  111. * Grays
  112. * Same as text color
  113. */
  114. // Text-color
  115. array( '#editor .editor-styles-wrapper .a8c-posts-list__item .a8c-posts-list-item__meta,
  116. #editor .editor-styles-wrapper .wp-block-image figcaption,
  117. #editor .editor-styles-wrapper .wp-block-latest-comments .wp-block-latest-comments__comment-date,
  118. #editor .editor-styles-wrapper .wp-block-latest-posts .wp-block-latest-posts__post-date,
  119. #editor .editor-styles-wrapper .wp-block-newspack-blocks-homepage-articles article .cat-links,
  120. #editor .editor-styles-wrapper .wp-block-newspack-blocks-homepage-articles article .entry-meta,
  121. #editor .editor-styles-wrapper .wp-block-pullquote .wp-block-pullquote__citation,
  122. #editor .editor-styles-wrapper .wp-block-pullquote cite,
  123. #editor .editor-styles-wrapper .wp-block-pullquote footer,
  124. #editor .editor-styles-wrapper .wp-block-quote .wp-block-quote__citation,
  125. #editor .editor-styles-wrapper .wp-block-quote cite,
  126. #editor .editor-styles-wrapper .wp-block-quote footer,
  127. #editor .editor-styles-wrapper .wp-block-quote.is-large .wp-block-quote__citation,
  128. #editor .editor-styles-wrapper .wp-block-quote.is-large cite,
  129. #editor .editor-styles-wrapper .wp-block-quote.is-large footer,
  130. #editor .editor-styles-wrapper .wp-block-quote.is-style-large .wp-block-quote__citation,
  131. #editor .editor-styles-wrapper .wp-block-quote.is-style-large cite,
  132. #editor .editor-styles-wrapper .wp-block-quote.is-style-large footer,
  133. #editor .editor-styles-wrapper .wp-block-video figcaption,
  134. #editor .editor-styles-wrapper figcaption', 'color' ),
  135. ), __( 'Text Color' ) );
  136. // Accent Color
  137. // $config-global--color-secondary-default
  138. add_editor_color_rule( 'fg1', '#0d1b24', array(
  139. // Background-color
  140. array( '#editor .editor-styles-wrapper .wp-block-media-text', 'background-color' ),
  141. /**
  142. * Utility Classes
  143. */
  144. // Text-color
  145. array( '#editor .editor-styles-wrapper .has-secondary-color[class]', 'color' ),
  146. // Background-color
  147. array( '#editor .editor-styles-wrapper .has-secondary-background-color[class]', 'background-color' ),
  148. ), __( 'Secondary Color' ) );
  149. /**
  150. * Custom CSS
  151. */
  152. function dalston_editor_custom_colors_extra_css() { ?>
  153. #editor .editor-styles-wrapper .has-background:not(.has-background-background-color) a:not(.wp-block-button__link),
  154. #editor .editor-styles-wrapper p.has-text-color a {
  155. color: currentColor;
  156. }
  157. <?php }
  158. add_theme_support( 'custom_colors_extra_css', 'dalston_editor_custom_colors_extra_css' );