jetpack.php 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. <?php
  2. /**
  3. * Jetpack Compatibility File
  4. * See: http://jetpack.me/
  5. *
  6. * @package Gazette
  7. */
  8. function gazette_jetpack_setup() {
  9. // Add theme support for Infinite Scroll.
  10. add_theme_support( 'infinite-scroll', array(
  11. 'container' => 'main',
  12. 'footer' => 'main',
  13. 'footer_widgets' => array( 'sidebar-2' ),
  14. 'wrapper' => false,
  15. ) );
  16. // Add theme support for Featured Content.
  17. add_theme_support( 'featured-content', array(
  18. 'filter' => 'gazette_get_featured_posts',
  19. 'description' => __( 'The featured content section displays on the front page above the header.', 'gazette' ),
  20. 'post_types' => array( 'post', 'page' ),
  21. 'max_posts' => 6,
  22. ) );
  23. // Add theme support for Responsive Videos.
  24. add_theme_support( 'jetpack-responsive-videos' );
  25. // Add theme support for Site Logo.
  26. add_image_size( 'gazette-logo', 270, 60 );
  27. add_theme_support( 'site-logo', array( 'size' => 'gazette-logo' ) );
  28. // Add theme support for Content Options.
  29. add_theme_support( 'jetpack-content-options', array(
  30. 'post-details' => array(
  31. 'stylesheet' => 'gazette-style',
  32. 'date' => '.posted-on, .group-blog:not(.single) .byline:before',
  33. 'categories' => '.cat-links',
  34. 'tags' => '.tags-links',
  35. 'author' => '.byline',
  36. ),
  37. 'featured-images' => array(
  38. 'archive' => true,
  39. 'post' => true,
  40. 'page' => true,
  41. 'fallback' => true,
  42. ),
  43. ) );
  44. }
  45. add_action( 'after_setup_theme', 'gazette_jetpack_setup' );
  46. /**
  47. * Featured Posts
  48. */
  49. function gazette_has_multiple_featured_posts() {
  50. $featured_posts = apply_filters( 'gazette_get_featured_posts', array() );
  51. if ( is_array( $featured_posts ) && 1 < count( $featured_posts ) ) {
  52. return true;
  53. }
  54. return false;
  55. }
  56. function gazette_get_featured_posts() {
  57. return apply_filters( 'gazette_get_featured_posts', false );
  58. }
  59. /**
  60. * Remove sharedaddy from excerpt.
  61. */
  62. function gazette_remove_sharedaddy() {
  63. remove_filter( 'the_excerpt', 'sharing_display', 19 );
  64. }
  65. add_action( 'loop_start', 'gazette_remove_sharedaddy' );
  66. /**
  67. * Return early if Site Logo is not available.
  68. */
  69. function gazette_the_site_logo() {
  70. if ( ! function_exists( 'jetpack_the_site_logo' ) ) {
  71. return;
  72. } else {
  73. jetpack_the_site_logo();
  74. }
  75. }
  76. /**
  77. * Show/Hide Featured Image on single posts view outside of the loop.
  78. */
  79. function gazette_jetpack_featured_image_display() {
  80. if ( ! function_exists( 'jetpack_featured_images_remove_post_thumbnail' ) ) {
  81. return true;
  82. } else {
  83. $options = get_theme_support( 'jetpack-content-options' );
  84. $featured_images = ( ! empty( $options[0]['featured-images'] ) ) ? $options[0]['featured-images'] : null;
  85. $settings = array(
  86. 'post-default' => ( isset( $featured_images['post-default'] ) && false === $featured_images['post-default'] ) ? '' : 1,
  87. 'page-default' => ( isset( $featured_images['page-default'] ) && false === $featured_images['page-default'] ) ? '' : 1,
  88. );
  89. $settings = array_merge( $settings, array(
  90. 'post-option' => get_option( 'jetpack_content_featured_images_post', $settings['post-default'] ),
  91. 'page-option' => get_option( 'jetpack_content_featured_images_page', $settings['page-default'] ),
  92. ) );
  93. if ( ( ! $settings['post-option'] && is_single() )
  94. || ( ! $settings['page-option'] && is_singular() && is_page() ) ) {
  95. return false;
  96. } else {
  97. return true;
  98. }
  99. }
  100. }
  101. /**
  102. * Custom function to check for a post thumbnail;
  103. * If Jetpack is not available, fall back to has_post_thumbnail()
  104. */
  105. function gazette_has_post_thumbnail( $post = null ) {
  106. if ( function_exists( 'jetpack_has_featured_image' ) ) {
  107. return jetpack_has_featured_image( $post );
  108. } else {
  109. return has_post_thumbnail( $post );
  110. }
  111. }