jetpack.php 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. <?php
  2. /**
  3. * Jetpack Compatibility File
  4. * See: http://jetpack.me/
  5. *
  6. * @package Canard
  7. */
  8. function canard_jetpack_setup() {
  9. // Add theme support for Infinite Scroll.
  10. add_theme_support( 'infinite-scroll', array(
  11. 'container' => 'main',
  12. 'footer' => 'page',
  13. 'footer_widgets' => array( 'sidebar-2' ),
  14. ) );
  15. // Add theme support for Featured Content.
  16. add_theme_support( 'featured-content', array(
  17. 'filter' => 'canard_get_featured_posts',
  18. 'description' => __( 'The featured content section displays on the front page above the header.', 'canard' ),
  19. 'max_posts' => 5,
  20. 'post_types' => array( 'post', 'page' ),
  21. ) );
  22. // Add theme support for Responsive Videos.
  23. add_theme_support( 'jetpack-responsive-videos' );
  24. // Add theme support for Site Logo.
  25. add_image_size( 'canard-logo', 400, 90 );
  26. add_theme_support( 'site-logo', array( 'size' => 'canard-logo' ) );
  27. // Add theme support for Content Options.
  28. add_theme_support( 'jetpack-content-options', array(
  29. 'post-details' => array(
  30. 'stylesheet' => 'canard-style',
  31. 'date' => '.posted-on, body:not(.group-blog) .entry-summary + .entry-meta > .comments-link:before',
  32. 'categories' => '.cat-links',
  33. 'tags' => '.tags-links',
  34. 'author' => '.byline, .group-blog .entry-summary + .entry-meta > .posted-on:before',
  35. 'comment' => '.comments-link',
  36. ),
  37. 'featured-images' => array(
  38. 'archive' => true,
  39. 'post' => true,
  40. 'page' => true,
  41. ),
  42. ) );
  43. }
  44. add_action( 'after_setup_theme', 'canard_jetpack_setup' );
  45. /**
  46. * Featured Posts
  47. */
  48. function canard_has_multiple_featured_posts() {
  49. $featured_posts = apply_filters( 'canard_get_featured_posts', array() );
  50. if ( is_array( $featured_posts ) && 1 < count( $featured_posts ) ) {
  51. return true;
  52. }
  53. return false;
  54. }
  55. function canard_get_featured_posts() {
  56. return apply_filters( 'canard_get_featured_posts', false );
  57. }
  58. /**
  59. * Remove sharedaddy from excerpt.
  60. */
  61. function canard_remove_sharedaddy() {
  62. remove_filter( 'the_excerpt', 'sharing_display', 19 );
  63. }
  64. add_action( 'loop_start', 'canard_remove_sharedaddy' );
  65. /**
  66. * Return early if Site Logo is not available.
  67. */
  68. function canard_the_site_logo() {
  69. if ( ! function_exists( 'jetpack_the_site_logo' ) ) {
  70. return;
  71. } else {
  72. jetpack_the_site_logo();
  73. }
  74. }
  75. /**
  76. * Show/Hide Featured Image on single posts view outside of the loop.
  77. */
  78. function canard_jetpack_featured_image_display() {
  79. if ( ! function_exists( 'jetpack_featured_images_remove_post_thumbnail' ) ) {
  80. return true;
  81. } else {
  82. $options = get_theme_support( 'jetpack-content-options' );
  83. $featured_images = ( ! empty( $options[0]['featured-images'] ) ) ? $options[0]['featured-images'] : null;
  84. $settings = array(
  85. 'post-default' => ( isset( $featured_images['post-default'] ) && false === $featured_images['post-default'] ) ? '' : 1,
  86. 'page-default' => ( isset( $featured_images['page-default'] ) && false === $featured_images['page-default'] ) ? '' : 1,
  87. );
  88. $settings = array_merge( $settings, array(
  89. 'post-option' => get_option( 'jetpack_content_featured_images_post', $settings['post-default'] ),
  90. 'page-option' => get_option( 'jetpack_content_featured_images_page', $settings['page-default'] ),
  91. ) );
  92. if ( ( ! $settings['post-option'] && is_single() )
  93. || ( ! $settings['page-option'] && is_singular() && is_page() ) ) {
  94. return false;
  95. } else {
  96. return true;
  97. }
  98. }
  99. }
  100. /**
  101. * Remove Post Format classes from Portfolio items.
  102. */
  103. function canard_jetpack_portfolio_classes( $classes ) {
  104. $post_format = get_post_format();
  105. if ( $post_format && ! is_wp_error( $post_format ) ) {
  106. $class = 'format-' . sanitize_html_class( $post_format );
  107. } else {
  108. $class = 'format-standard';
  109. }
  110. $class_key = array_search( $class, $classes );
  111. if ( false !== $class_key && 'jetpack-portfolio' === get_post_type() ) {
  112. unset( $classes[ $class_key ] );
  113. }
  114. return $classes;
  115. }
  116. add_filter( 'post_class', 'canard_jetpack_portfolio_classes' );