jetpack.php 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. <?php
  2. /**
  3. * Jetpack Compatibility File
  4. * See: http://jetpack.me/
  5. *
  6. * @package Apostrophe 2
  7. */
  8. function apostrophe_2_jetpack_setup() {
  9. // Add theme support for Infinite Scroll.
  10. add_theme_support( 'infinite-scroll', array(
  11. 'container' => 'main',
  12. 'footer' => 'colophon',
  13. 'footer_widgets' => 'footer-sidebar',
  14. 'wrapper' => false,
  15. ) );
  16. // Add theme support for Responsive Videos.
  17. add_theme_support( 'jetpack-responsive-videos' );
  18. // Add theme support for Featured Content.
  19. add_theme_support( 'featured-content', array(
  20. 'filter' => 'apostrophe_2_get_featured_posts',
  21. 'max_posts' => 6,
  22. ) );
  23. // Add theme support for Content Options.
  24. add_theme_support( 'jetpack-content-options', array(
  25. 'author-bio' => true,
  26. 'post-details' => array(
  27. 'stylesheet' => 'apostrophe-2-style',
  28. 'date' => '.entry-header .entry-meta, .posted-on',
  29. 'categories' => '.post-categories',
  30. 'tags' => '.post-tags',
  31. 'author' => '.byline',
  32. ),
  33. 'featured-images' => array(
  34. 'archive' => true,
  35. 'post' => true,
  36. 'post-default' => false,
  37. 'page' => true,
  38. 'page-default' => false,
  39. 'fallback' => true,
  40. ),
  41. ) );
  42. add_theme_support( 'jetpack-social-menu', 'svg' );
  43. }
  44. add_action( 'after_setup_theme', 'apostrophe_2_jetpack_setup' );
  45. /**
  46. * Custom function to check for a post thumbnail;
  47. * If Jetpack is not available, fall back to has_post_thumbnail()
  48. */
  49. function apostrophe_2_has_post_thumbnail( $post = null ) {
  50. if ( function_exists( 'jetpack_has_featured_image' ) ) {
  51. return jetpack_has_featured_image( $post );
  52. } else {
  53. return has_post_thumbnail( $post );
  54. }
  55. }
  56. /**
  57. * Return early if Social Menu is not available.
  58. */
  59. function apostrophe_2_social_menu() {
  60. if ( ! function_exists( 'jetpack_social_menu' ) ) {
  61. return;
  62. } else {
  63. jetpack_social_menu();
  64. }
  65. }
  66. /**
  67. * Author Bio Avatar Size.
  68. */
  69. function apostrophe_2_author_bio_avatar_size() {
  70. return 125; // in px
  71. }
  72. add_filter( 'jetpack_author_bio_avatar_size', 'apostrophe_2_author_bio_avatar_size' );
  73. /**
  74. * Change the wrapper id on the blog index page.
  75. */
  76. function apostrophe_2_infinite_scroll_js_settings( $settings ) {
  77. if ( is_home() || is_archive() || is_search() ) {
  78. $settings['id'] = 'posts-wrapper';
  79. }
  80. return $settings;
  81. }
  82. add_filter( 'infinite_scroll_js_settings', 'apostrophe_2_infinite_scroll_js_settings' );