jetpack.php 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. <?php
  2. /**
  3. * Jetpack Compatibility File
  4. * See: https://jetpack.me/
  5. *
  6. * @package Independent_Publisher_2
  7. */
  8. /**
  9. * Add theme support for Jetpack features.
  10. */
  11. function independent_publisher_2_jetpack_setup() {
  12. /*
  13. * Add theme support for Infinite Scroll.
  14. * See: https://jetpack.me/support/infinite-scroll/
  15. */
  16. add_theme_support( 'infinite-scroll', array(
  17. 'container' => 'main',
  18. 'render' => 'independent_publisher_2_infinite_scroll_render',
  19. 'footer' => 'page',
  20. ) );
  21. // Add theme support for Social Menu.
  22. add_theme_support( 'jetpack-social-menu', 'svg' );
  23. add_theme_support( 'jetpack-content-options', array(
  24. 'blog-display' => 'content',
  25. 'author-bio' => true,
  26. 'post-details' => array(
  27. 'stylesheet' => 'independent-publisher-2-style',
  28. 'date' => '.published-on, .post-permalink, .site-posted-on',
  29. 'categories' => '.cat-links',
  30. 'tags' => '.post-tags, .tags-links',
  31. 'author' => '.byline',
  32. 'comment' => '.comments-link',
  33. ),
  34. 'featured-images' => array(
  35. 'archive' => true,
  36. 'post' => true,
  37. 'post-default' => true,
  38. 'page' => true,
  39. 'page-default' => true,
  40. 'fallback' => true,
  41. 'fallback-default' => false,
  42. ),
  43. ) );
  44. /*
  45. * Add support for Responsive Videos
  46. * See: https://jetpack.me/support/responsive-videos/
  47. */
  48. add_theme_support( 'jetpack-responsive-videos' );
  49. }
  50. add_action( 'after_setup_theme', 'independent_publisher_2_jetpack_setup' );
  51. /**
  52. * Custom render function for Infinite Scroll.
  53. */
  54. function independent_publisher_2_infinite_scroll_render() {
  55. if ( class_exists( 'WooCommerce' ) && ( ip_woocommerce_is_shop_page() || is_product_taxonomy() || is_product_category() || is_product_tag() ) ) {
  56. ip_woocommerce_product_columns_wrapper();
  57. woocommerce_product_loop_start();
  58. }
  59. while ( have_posts() ) {
  60. the_post();
  61. if ( is_search() ) :
  62. get_template_part( 'template-parts/content', 'search' );
  63. elseif ( class_exists( 'WooCommerce' ) && ( ip_woocommerce_is_shop_page() || is_product_taxonomy() || is_product_category() || is_product_tag() ) ) :
  64. wc_get_template_part( 'content', 'product' );
  65. else :
  66. get_template_part( 'template-parts/content', get_post_format() );
  67. endif;
  68. }
  69. if ( class_exists( 'WooCommerce' ) && ( ip_woocommerce_is_shop_page() || is_product_taxonomy() || is_product_category() || is_product_tag() ) ) {
  70. woocommerce_product_loop_end();
  71. ip_woocommerce_product_columns_wrapper_close();
  72. }
  73. }
  74. /**
  75. * Return early if Social Menu is not available.
  76. */
  77. function independent_publisher_2_social_menu() {
  78. if ( ! function_exists( 'jetpack_social_menu' ) ) {
  79. return;
  80. } else {
  81. jetpack_social_menu();
  82. }
  83. }
  84. // Turn off infinite scroll if mobile + sidebar, or if social menu is active
  85. if ( function_exists( 'jetpack_is_mobile' ) && ! function_exists( 'independent_publisher_2_has_footer_widgets' ) ) {
  86. function independent_publisher_2_has_footer_widgets() {
  87. 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' ) ) ) )
  88. return true;
  89. return false;
  90. }
  91. } //endif
  92. add_filter( 'infinite_scroll_has_footer_widgets', 'independent_publisher_2_has_footer_widgets' );
  93. /**
  94. * Return early if Author Bio is not available.
  95. */
  96. function independent_publisher_2_author_bio() {
  97. if ( ! function_exists( 'jetpack_author_bio' ) ) {
  98. get_template_part( 'template-parts/content', 'author' );
  99. } else {
  100. jetpack_author_bio();
  101. }
  102. }
  103. /**
  104. * Author Bio Avatar Size.
  105. */
  106. function independent_publisher_2_author_bio_avatar_size() {
  107. return 80;
  108. }
  109. add_filter( 'jetpack_author_bio_avatar_size', 'independent_publisher_2_author_bio_avatar_size' );
  110. /**
  111. * Fall back to has_post_thumbnail() if jetpack_has_featured_image is not available
  112. */
  113. function independent_publisher_2_has_post_thumbnail( $post = null ) {
  114. if ( ! function_exists( 'jetpack_has_featured_image' ) ) {
  115. return has_post_thumbnail( $post );
  116. } else {
  117. return jetpack_has_featured_image( $post );
  118. }
  119. }
  120. /**
  121. * Show/Hide Featured Image outside of the loop.
  122. */
  123. function independent_publisher_2_jetpack_featured_image_display() {
  124. if ( ! function_exists( 'jetpack_featured_images_remove_post_thumbnail' ) ) {
  125. return true;
  126. } else {
  127. $options = get_theme_support( 'jetpack-content-options' );
  128. $featured_images = ( ! empty( $options[0]['featured-images'] ) ) ? $options[0]['featured-images'] : null;
  129. $settings = array(
  130. 'post-default' => ( isset( $featured_images['post-default'] ) && false === $featured_images['post-default'] ) ? '' : 1,
  131. 'page-default' => ( isset( $featured_images['page-default'] ) && false === $featured_images['page-default'] ) ? '' : 1,
  132. );
  133. $settings = array_merge( $settings, array(
  134. 'post-option' => get_option( 'jetpack_content_featured_images_post', $settings['post-default'] ),
  135. 'page-option' => get_option( 'jetpack_content_featured_images_page', $settings['page-default'] ),
  136. ) );
  137. if ( ( ! $settings['post-option'] && is_single() )
  138. || ( ! $settings['page-option'] && is_singular() && is_page() ) ) {
  139. return false;
  140. } else {
  141. return true;
  142. }
  143. }
  144. }