wpcom.php 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. <?php
  2. /**
  3. * WordPress.com-specific functions and definitions.
  4. *
  5. * This file is centrally included from `wp-content/mu-plugins/wpcom-theme-compat.php`.
  6. *
  7. * @package AltoFocus
  8. */
  9. /**
  10. * Adds support for wp.com-specific theme functions.
  11. *
  12. * @global array $themecolors
  13. */
  14. function altofocus_wpcom_setup() {
  15. global $themecolors;
  16. // Set theme colors for third party services.
  17. if ( ! isset( $themecolors ) ) {
  18. $themecolors = array(
  19. 'bg' => '#ffffff',
  20. 'border' => '#e38900',
  21. 'text' => '',
  22. 'link' => '',
  23. 'url' => '',
  24. );
  25. }
  26. // Add Print styles
  27. add_theme_support( 'print-style' );
  28. }
  29. add_action( 'after_setup_theme', 'altofocus_wpcom_setup' );
  30. /**
  31. * Reset a custom background arguments for WP.com to use the default callback.
  32. */
  33. function altofocus_wpcom_custom_background_args( $args ) {
  34. $args = array(
  35. 'default-attachment' => 'fixed',
  36. 'default-color' => 'ffffff',
  37. 'default-image' => '',
  38. 'default-position-x' => 'center',
  39. 'default-position-y' => 'center',
  40. 'default-repeat' => 'no-repeat',
  41. 'default-size' => 'auto',
  42. 'wp-head-callback' => '_custom_background_cb'
  43. );
  44. return $args;
  45. }
  46. add_filter( 'altofocus_custom_background_args', 'altofocus_wpcom_custom_background_args' );
  47. /**
  48. * De-queue Google fonts if custom fonts are being used instead
  49. */
  50. function altofocus_dequeue_fonts() {
  51. if ( class_exists( 'TypekitData' ) && class_exists( 'CustomDesign' ) && CustomDesign::is_upgrade_active() ) {
  52. $customfonts = TypekitData::get( 'families' );
  53. if ( $customfonts && $customfonts['site-title']['id'] && $customfonts['headings']['id'] && $customfonts['body-text']['id'] ) {
  54. wp_dequeue_style( 'altofocus-libre-baskerville' );
  55. wp_dequeue_style( 'altofocus-karla' );
  56. }
  57. }
  58. }
  59. add_action( 'wp_enqueue_scripts', 'altofocus_dequeue_fonts' );
  60. /**
  61. * WordPress.com specific styles
  62. */
  63. function altofocus_wpcom_styles() {
  64. wp_enqueue_style( 'altofocus-wpcom', get_template_directory_uri() . '/inc/style-wpcom.css', '20170303' );
  65. }
  66. add_action( 'wp_enqueue_scripts', 'altofocus_wpcom_styles' );