wpcom-editor-colors.php 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271
  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-background
  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', 'color' ),
  74. // Background-color
  75. array( '#editor .editor-styles-wrapper .wp-block-cover,
  76. #editor .editor-styles-wrapper .wp-block-cover-image', 'background-color' ),
  77. /**
  78. * Utility Classes
  79. */
  80. // Text-color
  81. array( '#editor .editor-styles-wrapper .has-background-background-color[class],
  82. #editor .editor-styles-wrapper .has-background-dark-background-color[class],
  83. #editor .editor-styles-wrapper .has-background-light-background-color[class],
  84. #editor .editor-styles-wrapper .has-foreground-color[class],
  85. #editor .editor-styles-wrapper .has-background-background-color[class] a', 'color' ),
  86. // Background-color
  87. array( '#editor .editor-styles-wrapper .has-foreground-background-color[class]', 'background-color' ),
  88. // Text-color darkened
  89. array( '#editor .editor-styles-wrapper .has-foreground-dark-color[class]', 'color', '-1' ),
  90. // Background-color darkened
  91. array( '#editor .editor-styles-wrapper .has-foreground-dark-background-color[class]', 'background-color', '-1' ),
  92. // Text-color brightened
  93. array( '#editor .editor-styles-wrapper .has-foreground-light-color[class]', 'color', '+2' ),
  94. // Background-color brightened
  95. array( '#editor .editor-styles-wrapper .has-foreground-light-background-color[class]', 'background-color', '+2' ),
  96. ), __( 'Text Color' ) );
  97. // Primary Color
  98. // --global--color-primary
  99. add_color_rule( 'link', '#000000', array(
  100. // Background-color
  101. array( '#editor .editor-styles-wrapper .wp-block-a8c-blog-posts + .button:active,
  102. #editor .editor-styles-wrapper .wp-block-search .wp-block-search__button:active', 'background-color' ),
  103. // Text-color
  104. array( '#editor .editor-styles-wrapper .wp-block-a8c-blog-posts .entry-title a,
  105. #editor .editor-styles-wrapper .wp-block-file .wp-block-file__textlink,
  106. #editor .editor-styles-wrapper a,
  107. #editor .editor-styles-wrapper a:active', 'color' ),
  108. /**
  109. * Utility Classes
  110. */
  111. // Background-color
  112. array( '#editor .editor-styles-wrapper .has-primary-background-color[class]', 'background-color' ),
  113. // Text-color
  114. array( '#editor .editor-styles-wrapper .has-primary-color[class],
  115. #editor .editor-styles-wrapper .has-black-background-color[class],
  116. #editor .editor-styles-wrapper .has-foreground-dark-color[class]', 'color' ),
  117. ), __( 'Primary Color' ) );
  118. // Secondary Color
  119. // --global--color-secondary
  120. add_color_rule( 'fg1', '#3C8067', array(
  121. // Text-color
  122. array( '#editor .editor-styles-wrapper .is-style-outline .wp-block-button__link,
  123. #editor .editor-styles-wrapper .wp-block-a8c-blog-posts .cat-links a:active,
  124. #editor .editor-styles-wrapper .wp-block-a8c-blog-posts .cat-links a:hover,
  125. #editor .editor-styles-wrapper .wp-block-a8c-blog-posts .entry-meta a:active,
  126. #editor .editor-styles-wrapper .wp-block-a8c-blog-posts .entry-meta a:hover,
  127. #editor .editor-styles-wrapper .wp-block-a8c-blog-posts .entry-title a:hover,
  128. #editor .editor-styles-wrapper .wp-block-a8c-blog-posts .more-link:active,
  129. #editor .editor-styles-wrapper .wp-block-a8c-blog-posts .more-link:hover,
  130. #editor .editor-styles-wrapper .wp-block-button__link.is-style-outline,
  131. #editor .editor-styles-wrapper .wp-block-navigation:not(.has-text-color) .wp-block-navigation-link > a:focus,
  132. #editor .editor-styles-wrapper .wp-block-navigation:not(.has-text-color) .wp-block-navigation-link > a:hover,
  133. #editor .editor-styles-wrapper a:focus,
  134. #editor .editor-styles-wrapper a:hover', 'color' ),
  135. // Background-color
  136. array( '#editor .editor-styles-wrapper .wp-block-a8c-blog-posts + .button,
  137. #editor .editor-styles-wrapper .wp-block-button:not(.is-style-outline) .wp-block-button__link,
  138. #editor .editor-styles-wrapper .wp-block-file .wp-block-file__button,
  139. #editor .editor-styles-wrapper .wp-block-search .wp-block-search__button', 'background-color' ),
  140. // border-bottom-color
  141. array( '#editor .editor-styles-wrapper .wp-block-file .wp-block-file__textlink,
  142. #editor .editor-styles-wrapper a', 'border-bottom-color' ),
  143. // border-left-color
  144. array( '#editor .editor-styles-wrapper .wp-block-quote,
  145. #editor .editor-styles-wrapper .wp-block-quote.is-large,
  146. #editor .editor-styles-wrapper .wp-block-quote.is-style-large', 'border-left-color' ),
  147. // border-right-color
  148. array( '#editor .editor-styles-wrapper .wp-block-quote.has-text-align-right,
  149. #editor .editor-styles-wrapper .wp-block-quote.is-large.has-text-align-right,
  150. #editor .editor-styles-wrapper .wp-block-quote.is-style-large.has-text-align-right', 'border-right-color' ),
  151. /**
  152. * Utility Classes
  153. */
  154. // Background-color
  155. array( '#editor .editor-styles-wrapper .has-secondary-background-color[class]', 'background-color' ),
  156. // Text-color
  157. array( '#editor .editor-styles-wrapper .has-secondary-color[class],
  158. #editor .editor-styles-wrapper .has-white-background-color[class]', 'color' ),
  159. ), __( 'Secondary Color' ) );
  160. // Tertiary Color
  161. // --global--color-tertiary
  162. add_color_rule( 'fg2', '#FAFBF6', array(
  163. // Background-color
  164. array( '#editor .editor-styles-wrapper .has-tertiary-background-color[class]', 'background-color' ),
  165. // Text-color
  166. array( '#editor .editor-styles-wrapper .has-tertiary-color[class],
  167. #editor .editor-styles-wrapper .wp-block-cover-image:not([class*="background-color"]) .block-editor-block-list__block,
  168. #editor .editor-styles-wrapper .wp-block-cover-image:not([class*="background-color"]) .wp-block-cover-image-text,
  169. #editor .editor-styles-wrapper .wp-block-cover-image:not([class*="background-color"]) .wp-block-cover-text,
  170. #editor .editor-styles-wrapper .wp-block-cover-image:not([class*="background-color"]) .wp-block-cover__inner-container,
  171. #editor .editor-styles-wrapper .wp-block-cover:not([class*="background-color"]) .block-editor-block-list__block,
  172. #editor .editor-styles-wrapper .wp-block-cover:not([class*="background-color"]) .wp-block-cover-image-text,
  173. #editor .editor-styles-wrapper .wp-block-cover:not([class*="background-color"]) .wp-block-cover-text,
  174. #editor .editor-styles-wrapper .wp-block-cover:not([class*="background-color"]) .wp-block-cover__inner-container', 'color' ),
  175. ), __( 'Tertiary Color' ) );
  176. /**
  177. * Custom CSS
  178. * The plugin takes the body of this function and applies it in a style tag in the document head.
  179. */
  180. function seedlet_custom_colors_extra_css() {
  181. $colors_array = get_theme_mod( 'colors_manager' );
  182. $color_bg = $colors_array['colors']['bg'];
  183. $color_fg1 = $colors_array['colors']['fg1'];
  184. $color_fg2 = $colors_array['colors']['fg2']; ?>
  185. /*
  186. * Custom gradients.
  187. */
  188. #editor .editor-styles-wrapper .has-hard-diagonal-gradient-background {
  189. background: linear-gradient(to bottom right, <?php echo $color_fg1; ?> 49.9%, <?php echo $color_fg2; ?> 50%);
  190. }
  191. #editor .editor-styles-wrapper .has-hard-diagonal-inverted-gradient-background {
  192. background: linear-gradient(to top left, <?php echo $color_fg1; ?> 49.9%, <?php echo $color_fg2; ?> 50%);
  193. }
  194. #editor .editor-styles-wrapper .has-diagonal-gradient-background {
  195. background: linear-gradient(to bottom right, <?php echo $color_fg1; ?>, <?php echo $color_fg2; ?>);
  196. }
  197. #editor .editor-styles-wrapper .has-diagonal-inverted-gradient-background {
  198. background: linear-gradient(to top left, <?php echo $color_fg1; ?>, <?php echo $color_fg2; ?>);
  199. }
  200. #editor .editor-styles-wrapper .has-hard-horizontal-gradient-background {
  201. background: linear-gradient(to bottom, <?php echo $color_fg1; ?> 50%, <?php echo $color_fg2; ?> 50%);
  202. }
  203. #editor .editor-styles-wrapper .has-hard-horizontal-inverted-gradient-background {
  204. background: linear-gradient(to top, <?php echo $color_fg1; ?> 50%, <?php echo $color_fg2; ?> 50%);
  205. }
  206. #editor .editor-styles-wrapper .has-horizontal-gradient-background {
  207. background: linear-gradient(to bottom, <?php echo $color_fg1; ?>, <?php echo $color_fg2; ?>);
  208. }
  209. #editor .editor-styles-wrapper .has-horizontal-inverted-gradient-background {
  210. background: linear-gradient(to top, <?php echo $color_fg1; ?>, <?php echo $color_fg2; ?>);
  211. }
  212. #editor .editor-styles-wrapper .has-stripe-gradient-background {
  213. background: linear-gradient(to bottom, transparent 20%, <?php echo $color_fg1; ?> 20%, <?php echo $color_fg1; ?> 80%, transparent 80%);
  214. }
  215. <?php }
  216. add_theme_support( 'custom_colors_extra_css', 'seedlet_custom_colors_extra_css' );