wpcom-colors.php 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. require_once __DIR__ . '/wpcom-colors-utils.php';
  3. seedlet_define_color_annotations(
  4. array(
  5. 'background' => '#FFFFFF',
  6. 'foreground' => '#000000',
  7. 'primary' => '#DB0042',
  8. 'secondary' => '#555555',
  9. 'tertiary' => '#FAFBF6',
  10. )
  11. );
  12. /**
  13. * Add a customizer message about dark mode.
  14. */
  15. if ( ! function_exists( 'spearhead_wpcom_customize_update' ) ) :
  16. function spearhead_wpcom_customize_update( $wp_customize ) {
  17. $wpcom_colors_array = get_theme_mod( 'colors_manager' );
  18. $default_palette = array(
  19. 'bg' => '#ffffff',
  20. 'txt' => '#000000',
  21. 'link' => '#db0042',
  22. 'fg1' => '#555555',
  23. 'fg2' => '#fafbf6',
  24. );
  25. if ( ! $wpcom_colors_array['colors'] || $default_palette === $wpcom_colors_array['colors'] ) :
  26. $wp_customize->add_setting( 'color_darkmode_disable' );
  27. $wp_customize->add_control(
  28. 'color_darkmode_disable',
  29. array(
  30. 'label' => esc_html__( 'Disable Dark Mode', 'spearhead' ),
  31. 'description' => sprintf(
  32. /* translators: %s: link to how to support system display modes */
  33. __( "Unless checked, this theme's default palette will display a dark color palette automatically for users who have dark mode enabled on their devices. <a href='%s' target='_blank'>Learn more about dark mode</a>.", 'spearhead' ),
  34. esc_url( 'https://www.a11yproject.com/posts/2020-01-23-operating-system-and-browser-accessibility-display-modes/' )
  35. ),
  36. 'section' => 'colors_manager_tool',
  37. 'priority' => 10, // Set to 10 so it appears near the top of the Colors & Backgrounds panel
  38. 'type' => 'checkbox',
  39. 'settings' => 'color_darkmode_disable',
  40. )
  41. );
  42. endif;
  43. }
  44. add_action( 'customize_register', 'spearhead_wpcom_customize_update' );
  45. endif;