jetpack.php 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. <?php
  2. /**
  3. * Jetpack Compatibility File
  4. * See: http://jetpack.com/
  5. *
  6. * @package Penscratch 2
  7. */
  8. /**
  9. * Jetpack Setup.
  10. */
  11. function penscratch_2_jetpack_setup() {
  12. // Add theme support for Infinite Scroll.
  13. add_theme_support( 'infinite-scroll', array(
  14. 'container' => 'main',
  15. 'footer' => 'page',
  16. ) );
  17. // Add theme support for Responsive Videos.
  18. add_theme_support( 'jetpack-responsive-videos' );
  19. // Add theme support for Social Menu.
  20. add_theme_support( 'jetpack-social-menu', 'svg' );
  21. // Add theme support for Content Options.
  22. add_theme_support( 'jetpack-content-options', array(
  23. 'blog-display' => 'content',
  24. 'author-bio' => true,
  25. 'post-details' => array(
  26. 'stylesheet' => 'penscratch-2-style',
  27. 'date' => '.posted-on, .byline .sep, body:not(.group-blog):not(.single) .byline + .sep',
  28. 'categories' => '.cat-links',
  29. 'tags' => '.tags-links',
  30. 'author' => '.byline .author, .group-blog .byline + .sep, .single .byline + .sep'
  31. ),
  32. 'featured-images' => array(
  33. 'archive' => true,
  34. 'post' => true,
  35. 'page' => true,
  36. 'fallback' => true,
  37. 'fallback-default' => false,
  38. ),
  39. ) );
  40. }
  41. add_action( 'after_setup_theme', 'penscratch_2_jetpack_setup' );
  42. // Turn off infinite scroll if mobile + sidebar, or if social menu is active
  43. if ( function_exists( 'jetpack_is_mobile' ) && ! function_exists( 'penscratch_2_has_footer_widgets' ) ) {
  44. function penscratch_2_has_footer_widgets() {
  45. if ( is_active_sidebar( 'sidebar-2' ) || is_active_sidebar( 'sidebar-3' ) || is_active_sidebar( 'sidebar-4' ) || has_nav_menu( 'jetpack-social-navigation' ) || ( ( jetpack_is_mobile( '', true ) && is_active_sidebar( 'sidebar-1' ) ) ) )
  46. return true;
  47. return false;
  48. }
  49. } //endif
  50. add_filter( 'infinite_scroll_has_footer_widgets', 'penscratch_2_has_footer_widgets' );
  51. /**
  52. * Return early if Social Menu is not available.
  53. */
  54. function penscratch_2_social_menu() {
  55. if ( ! function_exists( 'jetpack_social_menu' ) ) {
  56. return;
  57. } else {
  58. jetpack_social_menu();
  59. }
  60. }
  61. /**
  62. * Return early if Author Bio is not available.
  63. */
  64. function penscratch_2_author_bio() {
  65. if ( ! function_exists( 'jetpack_author_bio' ) ) {
  66. get_template_part( 'content', 'author' );
  67. } else {
  68. jetpack_author_bio();
  69. }
  70. }
  71. /**
  72. * Author Bio Avatar Size.
  73. */
  74. function penscratch_2_author_bio_avatar_size() {
  75. return 60;
  76. }
  77. add_filter( 'jetpack_author_bio_avatar_size', 'penscratch_2_author_bio_avatar_size' );
  78. /**
  79. * Custom function to check for a post thumbnail;
  80. * If Jetpack is not available, fall back to has_post_thumbnail()
  81. */
  82. function penscratch_2_has_post_thumbnail( $post = null ) {
  83. if ( function_exists( 'jetpack_has_featured_image' ) ) {
  84. return jetpack_has_featured_image( $post );
  85. } else {
  86. return has_post_thumbnail( $post );
  87. }
  88. }