wpcom.php 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. <?php
  2. /**
  3. * WordPress.com-specific functions and definitions
  4. * This file is centrally included from `wp-content/mu-plugins/wpcom-theme-compat.php`.
  5. *
  6. * @package Intergalactic 2
  7. */
  8. function intergalactic_2_theme_colors() {
  9. global $themecolors;
  10. /**
  11. * Set a default theme color array for WP.com.
  12. *
  13. * @global array $themecolors
  14. */
  15. if ( ! isset( $themecolors ) ) :
  16. $themecolors = array(
  17. 'bg' => 'ffffff',
  18. 'border' => 'cccccc',
  19. 'text' => '000000',
  20. 'link' => '222222',
  21. 'url' => '222222',
  22. );
  23. endif;
  24. // Add WP.com print styles
  25. add_theme_support( 'print-style' );
  26. }
  27. add_action( 'after_setup_theme', 'intergalactic_2_theme_colors' );
  28. /*
  29. * De-queue Google fonts if custom fonts are being used instead
  30. */
  31. function intergalactic_2_dequeue_fonts() {
  32. if ( class_exists( 'TypekitData' ) && class_exists( 'CustomDesign' ) && CustomDesign::is_upgrade_active() ) {
  33. $customfonts = TypekitData::get( 'families' );
  34. if ( $customfonts && $customfonts['site-title']['id'] && $customfonts['headings']['id'] && $customfonts['body-text']['id'] ) {
  35. wp_dequeue_style( 'intergalactic-lato' );
  36. }
  37. }
  38. }
  39. add_action( 'wp_enqueue_scripts', 'intergalactic_2_dequeue_fonts' );
  40. /* WordPress.com specific styles */
  41. function intergalactic_2_wpcom_styles() {
  42. wp_enqueue_style( 'intergalactic-wpcom', get_template_directory_uri() . '/inc/style-wpcom.css', '090414' );
  43. }
  44. add_action( 'wp_enqueue_scripts', 'intergalactic_2_wpcom_styles' );
  45. /**
  46. * Adds custom classes to the array of body classes.
  47. *
  48. * @param array $classes Classes for the body element.
  49. * @return array
  50. */
  51. function intergalactic_2_wpcom_body_classes( $classes ) {
  52. //Add a class of widgets-hidden if the sidebar is active for Direct Manipulation
  53. if ( is_active_sidebar( 'sidebar-1' ) ) {
  54. $classes[] = 'widgets-hidden';
  55. }
  56. return $classes;
  57. }
  58. add_filter( 'body_class', 'intergalactic_2_wpcom_body_classes' );
  59. /**
  60. * Make sure background colours work for users without Custom Colours.
  61. *
  62. */
  63. function intergalactic_2_background_fix() {
  64. $background_color = get_theme_mod( 'background_color','ffffff' );
  65. $background_styles = '.entry-content-wrapper {';
  66. $background_styles .= 'background-color: #' . $background_color . '; ';
  67. $background_styles .= '}';
  68. wp_add_inline_style( 'intergalactic-2-style', $background_styles );
  69. }
  70. add_action( 'wp_enqueue_scripts', 'intergalactic_2_background_fix' );