jetpack.php 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. <?php
  2. /**
  3. * Jetpack Compatibility File
  4. *
  5. * @link https://jetpack.com/
  6. *
  7. * @package Radcliffe 2
  8. */
  9. /**
  10. * Jetpack setup function.
  11. *
  12. * See: https://jetpack.com/support/infinite-scroll/
  13. * See: https://jetpack.com/support/responsive-videos/
  14. */
  15. function radcliffe_2_jetpack_setup() {
  16. // Add theme support for Infinite Scroll.
  17. add_theme_support( 'infinite-scroll', array(
  18. 'container' => 'main',
  19. 'render' => 'radcliffe_2_infinite_scroll_render',
  20. 'footer' => 'page',
  21. 'wrapper' => false,
  22. 'footer_widgets' => array( 'sidebar-1', 'sidebar-2', 'sidebar-3' ),
  23. ) );
  24. // Add theme support for Responsive Videos.
  25. add_theme_support( 'jetpack-responsive-videos' );
  26. // Add theme support for Content Options.
  27. add_theme_support( 'jetpack-content-options', array(
  28. 'author-bio' => true,
  29. 'avatar-default' => false,
  30. 'post-details' => array(
  31. 'stylesheet' => 'radcliffe-2-style',
  32. 'date' => '.posted-on',
  33. 'categories' => '.cat-links',
  34. 'tags' => '.tags-links',
  35. 'author' => '.byline',
  36. 'comment' => '.comments-link',
  37. ),
  38. 'featured-images' => array(
  39. 'archive' => true,
  40. 'post' => true,
  41. 'page' => true,
  42. 'fallback' => true,
  43. 'fallback-default' => false,
  44. ),
  45. ) );
  46. // Add theme support for Social Menus
  47. add_theme_support( 'jetpack-social-menu', 'svg' );
  48. }
  49. add_action( 'after_setup_theme', 'radcliffe_2_jetpack_setup' );
  50. /**
  51. * Custom render function for Infinite Scroll.
  52. */
  53. function radcliffe_2_infinite_scroll_render() {
  54. if ( class_exists( 'WooCommerce' ) && ( radcliffe_2_woocommerce_is_shop_page() || is_product_taxonomy() || is_product_category() || is_product_tag() ) ) {
  55. radcliffe_2_woocommerce_product_columns_wrapper();
  56. woocommerce_product_loop_start();
  57. }
  58. while ( have_posts() ) {
  59. the_post();
  60. if ( is_search() ) :
  61. get_template_part( 'template-parts/content', 'search' );
  62. elseif ( class_exists( 'WooCommerce' ) && ( radcliffe_2_woocommerce_is_shop_page() || is_product_taxonomy() || is_product_category() || is_product_tag() ) ) :
  63. wc_get_template_part( 'content', 'product' );
  64. else :
  65. get_template_part( 'template-parts/content', get_post_format() );
  66. endif;
  67. }
  68. if ( class_exists( 'WooCommerce' ) && ( radcliffe_2_woocommerce_is_shop_page() || is_product_taxonomy() || is_product_category() || is_product_tag() ) ) {
  69. woocommerce_product_loop_end();
  70. radcliffe_2_woocommerce_product_columns_wrapper_close();
  71. }
  72. }
  73. /**
  74. * Custom function to check for a post thumbnail;
  75. * If Jetpack is not available, fall back to has_post_thumbnail()
  76. */
  77. function radcliffe_2_has_post_thumbnail( $post = null ) {
  78. if ( function_exists( 'jetpack_has_featured_image' ) ) {
  79. return jetpack_has_featured_image( $post );
  80. } else {
  81. return has_post_thumbnail( $post );
  82. }
  83. }
  84. /**
  85. * Return early if Author Bio is not available.
  86. */
  87. function radcliffe_2_author_bio() {
  88. if ( ! function_exists( 'jetpack_author_bio' ) ) {
  89. get_template_part( 'template-parts/content', 'author' );
  90. } else {
  91. jetpack_author_bio();
  92. }
  93. }
  94. /**
  95. * Author Bio Avatar Size.
  96. */
  97. function radcliffe_2_author_bio_avatar_size() {
  98. return 60; // in px
  99. }
  100. add_filter( 'jetpack_author_bio_avatar_size', 'radcliffe_2_author_bio_avatar_size' );
  101. /**
  102. * Custom function to get the URL of a post thumbnail;
  103. * If Jetpack is not available, fall back to wp_get_attachment_image_src()
  104. */
  105. function radcliffe_2_get_attachment_image_src( $post_id, $post_thumbnail_id, $size ) {
  106. if ( function_exists( 'jetpack_featured_images_fallback_get_image_src' ) ) {
  107. return jetpack_featured_images_fallback_get_image_src( $post_id, $post_thumbnail_id, $size );
  108. } else {
  109. $attachment = wp_get_attachment_image_src( $post_thumbnail_id, $size ); // Attachment array
  110. $url = $attachment[0]; // Attachment URL
  111. return $url;
  112. }
  113. }
  114. /**
  115. * Return early if Social Menu is not available.
  116. */
  117. function radcliffe_2_social_menu() {
  118. if ( ! function_exists( 'jetpack_social_menu' ) ) {
  119. return;
  120. } else {
  121. jetpack_social_menu();
  122. }
  123. }