jetpack.php 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. <?php
  2. /**
  3. * Jetpack Compatibility File
  4. * See: https://jetpack.me/
  5. *
  6. * @package Button 2
  7. */
  8. /**
  9. * Add theme support for Infinite Scroll.
  10. * See: https://jetpack.me/support/infinite-scroll/
  11. *
  12. * @since button 1.0
  13. */
  14. function button_2_jetpack_setup() {
  15. add_theme_support( 'infinite-scroll', array(
  16. 'container' => 'main',
  17. 'render' => 'button_2_infinite_scroll_render',
  18. 'footer' => 'page',
  19. ) );
  20. // Add theme support for Social Menu.
  21. add_theme_support( 'jetpack-social-menu', 'svg' );
  22. add_theme_support( 'jetpack-content-options', array(
  23. 'blog-display' => 'content',
  24. 'author-bio' => true,
  25. 'post-details' => array(
  26. 'stylesheet' => 'button-2-style',
  27. 'date' => '.posted-on',
  28. 'categories' => '.cat-links',
  29. 'tags' => '.tags-links',
  30. 'author' => '.byline',
  31. ),
  32. 'featured-images' => array(
  33. 'archive' => true,
  34. 'post' => true,
  35. 'post-default' => false,
  36. 'page' => true,
  37. 'page-default' => false,
  38. 'fallback' => true,
  39. 'fallback-default' => false,
  40. ),
  41. ) );
  42. add_theme_support( 'jetpack-responsive-videos' );
  43. } // end function button_2_jetpack_setup
  44. add_action( 'after_setup_theme', 'button_2_jetpack_setup' );
  45. // Turn off infinite scroll if mobile + sidebar, or if social menu is active
  46. if ( function_exists( 'jetpack_is_mobile' ) && ! function_exists( 'button_2_has_footer_widgets' ) ) {
  47. function button_2_has_footer_widgets() {
  48. if ( is_active_sidebar( 'sidebar-2' ) || is_active_sidebar( 'sidebar-3' ) || is_active_sidebar( 'sidebar-4' ) || ( ( jetpack_is_mobile( '', true ) && is_active_sidebar( 'sidebar-1' ) ) ) )
  49. return true;
  50. return false;
  51. }
  52. } //endif
  53. add_filter( 'infinite_scroll_has_footer_widgets', 'button_2_has_footer_widgets' );
  54. /**
  55. * Custom render function for Infinite Scroll.
  56. *
  57. * @since button 1.0
  58. */
  59. function button_2_infinite_scroll_render() {
  60. if ( class_exists( 'WooCommerce' ) && ( is_shop() || is_product_taxonomy() || is_product_category() || is_product_tag() ) ) {
  61. button_2_woocommerce_product_columns_wrapper();
  62. woocommerce_product_loop_start();
  63. }
  64. while ( have_posts() ) {
  65. the_post();
  66. if ( class_exists( 'WooCommerce' ) && ( is_shop() || is_product_taxonomy() || is_product_category() || is_product_tag() ) ) :
  67. wc_get_template_part( 'content', 'product' );
  68. else :
  69. get_template_part( 'components/content', get_post_format() );
  70. endif;
  71. }
  72. if ( class_exists( 'WooCommerce' ) && ( is_shop() || is_product_taxonomy() || is_product_category() || is_product_tag() ) ) {
  73. woocommerce_product_loop_end();
  74. button_2_woocommerce_product_columns_wrapper_close();
  75. }
  76. } // end function button_2_infinite_scroll_render
  77. /**
  78. * Return early if Social Menu is not available.
  79. */
  80. function button_2_social_menu() {
  81. if ( ! function_exists( 'jetpack_social_menu' ) ) {
  82. return;
  83. } else {
  84. jetpack_social_menu();
  85. }
  86. }
  87. /**
  88. * Return early if Author Bio is not available.
  89. */
  90. function button_2_author_bio() {
  91. if ( ! function_exists( 'jetpack_author_bio' ) ) {
  92. get_template_part( 'components/content', 'author' );
  93. } else {
  94. jetpack_author_bio();
  95. }
  96. }
  97. /**
  98. * Author Bio Avatar Size.
  99. */
  100. function button_2_author_bio_avatar_size() {
  101. return 80;
  102. }
  103. add_filter( 'jetpack_author_bio_avatar_size', 'button_2_author_bio_avatar_size' );
  104. /**
  105. * Load Jetpack sharing buttons and likes.
  106. *
  107. * @since button 1.0
  108. */
  109. function button_2_post_flair() {
  110. // Sharing buttons
  111. if ( function_exists( 'sharing_display' ) ) {
  112. sharing_display( '', true );
  113. }
  114. // Likes
  115. if ( class_exists( 'Jetpack_Likes' ) ) {
  116. $custom_likes = new Jetpack_Likes;
  117. echo $custom_likes->post_likes( '' );
  118. }
  119. }
  120. /**
  121. * Custom function to check for a post thumbnail;
  122. * If Jetpack is not available, fall back to has_post_thumbnail()
  123. */
  124. function button_2_has_post_thumbnail( $post = null ) {
  125. if ( function_exists( 'jetpack_has_featured_image' ) ) {
  126. return jetpack_has_featured_image( $post );
  127. } else {
  128. return has_post_thumbnail( $post );
  129. }
  130. }