wpcom-editor-colors.php 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275
  1. <?php
  2. /*
  3. * Custom Editor Colors: Seedlet
  4. */
  5. // Background Color
  6. // --global--color-background
  7. add_color_rule( 'bg', '#FFFFFF', array(
  8. // Background-color
  9. array( '#editor .editor-styles-wrapper .wp-block-navigation .wp-block-navigation__container,
  10. #editor .editor-styles-wrapper', 'background-color' ),
  11. // Text-color
  12. array( '#editor .editor-styles-wrapper .wp-block-a8c-blog-posts + .button,
  13. #editor .editor-styles-wrapper .wp-block-a8c-blog-posts + .button:active,
  14. #editor .editor-styles-wrapper .wp-block-a8c-blog-posts + .button:focus,
  15. #editor .editor-styles-wrapper .wp-block-a8c-blog-posts + .button:hover,
  16. #editor .editor-styles-wrapper .wp-block-a8c-blog-posts + .has-focus.button,
  17. #editor .editor-styles-wrapper .wp-block-button__link,
  18. #editor .editor-styles-wrapper .wp-block-button__link.has-focus,
  19. #editor .editor-styles-wrapper .wp-block-button__link:focus,
  20. #editor .editor-styles-wrapper .wp-block-button__link:hover,
  21. #editor .editor-styles-wrapper .wp-block-file .wp-block-file__button,
  22. #editor .editor-styles-wrapper .wp-block-file .wp-block-file__button.has-focus,
  23. #editor .editor-styles-wrapper .wp-block-file .wp-block-file__button:focus,
  24. #editor .editor-styles-wrapper .wp-block-file .wp-block-file__button:hover,
  25. #editor .editor-styles-wrapper .wp-block-pullquote.is-style-solid-color,
  26. #editor .editor-styles-wrapper .wp-block-search .has-focus.wp-block-search__button,
  27. #editor .editor-styles-wrapper .wp-block-search .wp-block-search__button,
  28. #editor .editor-styles-wrapper .wp-block-search .wp-block-search__button:active,
  29. #editor .editor-styles-wrapper .wp-block-search .wp-block-search__button:focus,
  30. #editor .editor-styles-wrapper .wp-block-search .wp-block-search__button:hover', 'color' ),
  31. /**
  32. * Utility Classes
  33. */
  34. // Text-color
  35. array( '#editor .editor-styles-wrapper .has-primary-background-color,
  36. #editor .editor-styles-wrapper .has-secondary-background-color,
  37. #editor .editor-styles-wrapper .has-foreground-background-color,
  38. #editor .editor-styles-wrapper .has-foreground-dark-background-color,
  39. #editor .editor-styles-wrapper .has-foreground-light-background-color,
  40. #editor .editor-styles-wrapper .has-background-color,
  41. #editor .editor-styles-wrapper .has-background:not(.has-background-background-color) a', 'color' ),
  42. // Border-bottom-color
  43. array( '#editor .editor-styles-wrapper .has-secondary-background-color[class] a', 'border-bottom-color' ),
  44. // Background-color
  45. array( '#editor .editor-styles-wrapper .has-background-background-color[class]', 'background-color' ),
  46. // Text-color darkened
  47. array( '#editor .editor-styles-wrapper .has-background-dark-color[class]', 'color', '-1' ),
  48. // Background-color darkened
  49. array( '#editor .editor-styles-wrapper .has-background-dark-background-color[class]', 'background-color', '-1' ),
  50. // Text-color lightened
  51. array( '#editor .editor-styles-wrapper .has-background-light-color[class]', 'color', '+1' ),
  52. // Background-color lightened
  53. array( '#editor .editor-styles-wrapper .has-background-light-background-color[class]', 'background-color', '+1' ),
  54. ), __( 'Background Color' ) );
  55. // Foreground Color
  56. // --global--color-foreground-light
  57. add_color_rule( 'txt', '#444444', array(
  58. // Text-color
  59. array( '#editor .editor-styles-wrapper,
  60. #editor .editor-styles-wrapper .wp-block-a8c-blog-posts .cat-links,
  61. #editor .editor-styles-wrapper .wp-block-a8c-blog-posts .entry-meta,
  62. #editor .editor-styles-wrapper .wp-block-latest-posts .wp-block-latest-posts__post-date,
  63. #editor .editor-styles-wrapper .wp-block-pullquote .wp-block-pullquote__citation,
  64. #editor .editor-styles-wrapper .wp-block-pullquote cite,
  65. #editor .editor-styles-wrapper .wp-block-pullquote footer,
  66. #editor .editor-styles-wrapper .wp-block-quote .wp-block-quote__citation,
  67. #editor .editor-styles-wrapper .wp-caption,
  68. #editor .editor-styles-wrapper .wp-caption-text,
  69. #editor .editor-styles-wrapper blockquote cite,
  70. #editor .editor-styles-wrapper blockquote footer,
  71. #editor .editor-styles-wrapper figcaption,
  72. #editor .editor-styles-wrapper .editor-post-title .editor-post-title__input,
  73. #editor .editor-styles-wrapper .editor-post-title .editor-post-title__input::placeholder
  74. #editor .editor-styles-wrapper .has-tertiary-background-color[class],
  75. #editor .editor-styles-wrapper .has-tertiary-background-color[class] a,
  76. #editor .editor-styles-wrapper .has-tertiary-background-color[class]:not(.has-text-color)
  77. #editor .editor-styles-wrapper .has-tertiary-background-color[class]:not(.has-text-color) a', 'color' ),
  78. // Background-color
  79. array( '#editor .editor-styles-wrapper .wp-block-cover,
  80. #editor .editor-styles-wrapper .wp-block-cover-image', 'background-color' ),
  81. /**
  82. * Utility Classes
  83. */
  84. // Text-color
  85. array( '#editor .editor-styles-wrapper .has-background-background-color[class],
  86. #editor .editor-styles-wrapper .has-background-dark-background-color[class],
  87. #editor .editor-styles-wrapper .has-background-light-background-color[class],
  88. #editor .editor-styles-wrapper .has-foreground-color[class],
  89. #editor .editor-styles-wrapper .has-background-background-color[class] a', 'color' ),
  90. // Background-color
  91. array( '#editor .editor-styles-wrapper .has-foreground-background-color[class]', 'background-color' ),
  92. // Text-color darkened
  93. array( '#editor .editor-styles-wrapper .has-foreground-dark-color[class]', 'color', '-1' ),
  94. // Background-color darkened
  95. array( '#editor .editor-styles-wrapper .has-foreground-dark-background-color[class]', 'background-color', '-1' ),
  96. // Text-color brightened
  97. array( '#editor .editor-styles-wrapper .has-foreground-light-color[class]', 'color', '+2' ),
  98. // Background-color brightened
  99. array( '#editor .editor-styles-wrapper .has-foreground-light-background-color[class]', 'background-color', '+2' ),
  100. ), __( 'Text Color' ) );
  101. // Primary Color
  102. // --global--color-primary
  103. add_color_rule( 'link', '#000000', array(
  104. // Background-color
  105. array( '#editor .editor-styles-wrapper .wp-block-a8c-blog-posts + .button:active,
  106. #editor .editor-styles-wrapper .wp-block-search .wp-block-search__button:active', 'background-color' ),
  107. // Text-color
  108. array( '#editor .editor-styles-wrapper .wp-block-a8c-blog-posts .entry-title a,
  109. #editor .editor-styles-wrapper .wp-block-file .wp-block-file__textlink,
  110. #editor .editor-styles-wrapper a,
  111. #editor .editor-styles-wrapper a:active', 'color' ),
  112. /**
  113. * Utility Classes
  114. */
  115. // Background-color
  116. array( '#editor .editor-styles-wrapper .has-primary-background-color[class]', 'background-color' ),
  117. // Text-color
  118. array( '#editor .editor-styles-wrapper .has-primary-color[class],
  119. #editor .editor-styles-wrapper .has-black-background-color[class],
  120. #editor .editor-styles-wrapper .has-foreground-dark-color[class]', 'color' ),
  121. ), __( 'Primary Color' ) );
  122. // Secondary Color
  123. // --global--color-secondary
  124. add_color_rule( 'fg1', '#3C8067', array(
  125. // Text-color
  126. array( '#editor .editor-styles-wrapper .is-style-outline .wp-block-button__link,
  127. #editor .editor-styles-wrapper .wp-block-a8c-blog-posts .cat-links a:active,
  128. #editor .editor-styles-wrapper .wp-block-a8c-blog-posts .cat-links a:hover,
  129. #editor .editor-styles-wrapper .wp-block-a8c-blog-posts .entry-meta a:active,
  130. #editor .editor-styles-wrapper .wp-block-a8c-blog-posts .entry-meta a:hover,
  131. #editor .editor-styles-wrapper .wp-block-a8c-blog-posts .entry-title a:hover,
  132. #editor .editor-styles-wrapper .wp-block-a8c-blog-posts .more-link:active,
  133. #editor .editor-styles-wrapper .wp-block-a8c-blog-posts .more-link:hover,
  134. #editor .editor-styles-wrapper .wp-block-button__link.is-style-outline,
  135. #editor .editor-styles-wrapper .wp-block-navigation:not(.has-text-color) .wp-block-navigation-link > a:focus,
  136. #editor .editor-styles-wrapper .wp-block-navigation:not(.has-text-color) .wp-block-navigation-link > a:hover,
  137. #editor .editor-styles-wrapper a:focus,
  138. #editor .editor-styles-wrapper a:hover', 'color' ),
  139. // Background-color
  140. array( '#editor .editor-styles-wrapper .wp-block-a8c-blog-posts + .button,
  141. #editor .editor-styles-wrapper .wp-block-button:not(.is-style-outline) .wp-block-button__link,
  142. #editor .editor-styles-wrapper .wp-block-file .wp-block-file__button,
  143. #editor .editor-styles-wrapper .wp-block-search .wp-block-search__button', 'background-color' ),
  144. // border-bottom-color
  145. array( '#editor .editor-styles-wrapper .wp-block-file .wp-block-file__textlink,
  146. #editor .editor-styles-wrapper a', 'border-bottom-color' ),
  147. // border-left-color
  148. array( '#editor .editor-styles-wrapper .wp-block-quote,
  149. #editor .editor-styles-wrapper .wp-block-quote.is-large,
  150. #editor .editor-styles-wrapper .wp-block-quote.is-style-large', 'border-left-color' ),
  151. // border-right-color
  152. array( '#editor .editor-styles-wrapper .wp-block-quote.has-text-align-right,
  153. #editor .editor-styles-wrapper .wp-block-quote.is-large.has-text-align-right,
  154. #editor .editor-styles-wrapper .wp-block-quote.is-style-large.has-text-align-right', 'border-right-color' ),
  155. /**
  156. * Utility Classes
  157. */
  158. // Background-color
  159. array( '#editor .editor-styles-wrapper .has-secondary-background-color[class]', 'background-color' ),
  160. // Text-color
  161. array( '#editor .editor-styles-wrapper .has-secondary-color[class],
  162. #editor .editor-styles-wrapper .has-white-background-color[class]', 'color' ),
  163. ), __( 'Secondary Color' ) );
  164. // Tertiary Color
  165. // --global--color-tertiary
  166. add_color_rule( 'fg2', '#FAFBF6', array(
  167. // Background-color
  168. array( '#editor .editor-styles-wrapper .has-tertiary-background-color[class]', 'background-color' ),
  169. // Text-color
  170. array( '#editor .editor-styles-wrapper .has-tertiary-color[class],
  171. #editor .editor-styles-wrapper .wp-block-cover-image:not([class*="background-color"]) .block-editor-block-list__block,
  172. #editor .editor-styles-wrapper .wp-block-cover-image:not([class*="background-color"]) .wp-block-cover-image-text,
  173. #editor .editor-styles-wrapper .wp-block-cover-image:not([class*="background-color"]) .wp-block-cover-text,
  174. #editor .editor-styles-wrapper .wp-block-cover-image:not([class*="background-color"]) .wp-block-cover__inner-container,
  175. #editor .editor-styles-wrapper .wp-block-cover:not([class*="background-color"]) .block-editor-block-list__block,
  176. #editor .editor-styles-wrapper .wp-block-cover:not([class*="background-color"]) .wp-block-cover-image-text,
  177. #editor .editor-styles-wrapper .wp-block-cover:not([class*="background-color"]) .wp-block-cover-text,
  178. #editor .editor-styles-wrapper .wp-block-cover:not([class*="background-color"]) .wp-block-cover__inner-container', 'color' ),
  179. ), __( 'Tertiary Color' ) );
  180. /**
  181. * Custom CSS
  182. * The plugin takes the body of this function and applies it in a style tag in the document head.
  183. */
  184. function seedlet_custom_colors_extra_css() {
  185. $colors_array = get_theme_mod( 'colors_manager' );
  186. $color_bg = $colors_array['colors']['bg'];
  187. $color_fg1 = $colors_array['colors']['fg1'];
  188. $color_fg2 = $colors_array['colors']['fg2']; ?>
  189. /*
  190. * Custom gradients.
  191. */
  192. #editor .editor-styles-wrapper .has-hard-diagonal-gradient-background {
  193. background: linear-gradient(to bottom right, <?php echo $color_fg1; ?> 49.9%, <?php echo $color_fg2; ?> 50%);
  194. }
  195. #editor .editor-styles-wrapper .has-hard-diagonal-inverted-gradient-background {
  196. background: linear-gradient(to top left, <?php echo $color_fg1; ?> 49.9%, <?php echo $color_fg2; ?> 50%);
  197. }
  198. #editor .editor-styles-wrapper .has-diagonal-gradient-background {
  199. background: linear-gradient(to bottom right, <?php echo $color_fg1; ?>, <?php echo $color_fg2; ?>);
  200. }
  201. #editor .editor-styles-wrapper .has-diagonal-inverted-gradient-background {
  202. background: linear-gradient(to top left, <?php echo $color_fg1; ?>, <?php echo $color_fg2; ?>);
  203. }
  204. #editor .editor-styles-wrapper .has-hard-horizontal-gradient-background {
  205. background: linear-gradient(to bottom, <?php echo $color_fg1; ?> 50%, <?php echo $color_fg2; ?> 50%);
  206. }
  207. #editor .editor-styles-wrapper .has-hard-horizontal-inverted-gradient-background {
  208. background: linear-gradient(to top, <?php echo $color_fg1; ?> 50%, <?php echo $color_fg2; ?> 50%);
  209. }
  210. #editor .editor-styles-wrapper .has-horizontal-gradient-background {
  211. background: linear-gradient(to bottom, <?php echo $color_fg1; ?>, <?php echo $color_fg2; ?>);
  212. }
  213. #editor .editor-styles-wrapper .has-horizontal-inverted-gradient-background {
  214. background: linear-gradient(to top, <?php echo $color_fg1; ?>, <?php echo $color_fg2; ?>);
  215. }
  216. #editor .editor-styles-wrapper .has-stripe-gradient-background {
  217. background: linear-gradient(to bottom, transparent 20%, <?php echo $color_fg1; ?> 20%, <?php echo $color_fg1; ?> 80%, transparent 80%);
  218. }
  219. <?php }
  220. add_theme_support( 'custom_colors_extra_css', 'seedlet_custom_colors_extra_css' );