jetpack.php 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. <?php
  2. /**
  3. * Jetpack Compatibility File
  4. * See: https://jetpack.com/
  5. *
  6. * @package Pique
  7. */
  8. function pique_jetpack_setup() {
  9. // Add theme support for Infinite Scroll.
  10. add_theme_support( 'infinite-scroll', array(
  11. 'container' => 'main',
  12. 'wrapper' => false,
  13. 'render' => 'pique_infinite_scroll_render',
  14. 'footer' => 'tertiary',
  15. 'footer_widgets' => array( 'sidebar-2', 'sidebar-3', 'sidebar-4' ),
  16. ) );
  17. // Add theme support for Responsive Videos.
  18. add_theme_support( 'jetpack-responsive-videos' );
  19. // Add theme support for Site Logo.
  20. add_image_size( 'pique-logo', 2000, 200 );
  21. add_theme_support( 'site-logo', array( 'size' => 'pique-logo' ) );
  22. // Add theme support for Testimonial CPT.
  23. add_theme_support( 'jetpack-testimonial' );
  24. // Add theme support for Content Options.
  25. add_theme_support( 'jetpack-content-options', array(
  26. 'blog-display' => array(
  27. 'content',
  28. 'excerpt',
  29. ),
  30. 'post-details' => array(
  31. 'stylesheet' => 'pique-style',
  32. 'date' => '.posted-on',
  33. 'categories' => '.cat-links',
  34. 'tags' => '.tags-links',
  35. 'author' => '.byline',
  36. ),
  37. 'featured-images' => array(
  38. 'archive' => true,
  39. 'fallback' => true,
  40. 'fallback-default' => false,
  41. ),
  42. ) );
  43. } // end function pique_jetpack_setup
  44. add_action( 'after_setup_theme', 'pique_jetpack_setup' );
  45. /**
  46. * Custom render function for Infinite Scroll.
  47. */
  48. function pique_infinite_scroll_render() {
  49. if ( class_exists( 'WooCommerce' ) && ( is_shop() || is_product_taxonomy() || is_product_category() || is_product_tag() ) ) {
  50. pique_woocommerce_product_columns_wrapper();
  51. woocommerce_product_loop_start();
  52. }
  53. while ( have_posts() ) {
  54. the_post();
  55. if ( is_search() ) :
  56. get_template_part( 'template-parts/content', 'search' );
  57. elseif ( class_exists( 'WooCommerce' ) && ( is_shop() || is_product_taxonomy() || is_product_category() || is_product_tag() ) ) :
  58. wc_get_template_part( 'content', 'product' );
  59. else :
  60. get_template_part( 'components/content', get_post_format() );
  61. endif;
  62. }
  63. if ( class_exists( 'WooCommerce' ) && ( is_shop() || is_product_taxonomy() || is_product_category() || is_product_tag() ) ) {
  64. woocommerce_product_loop_end();
  65. pique_woocommerce_product_columns_wrapper_close();
  66. }
  67. } // end function pique_infinite_scroll_render
  68. /**
  69. * Return early if Site Logo is not available.
  70. *
  71. * @since Pique 1.0
  72. */
  73. function pique_the_site_logo() {
  74. if ( ! function_exists( 'jetpack_the_site_logo' ) ) {
  75. return;
  76. } else {
  77. jetpack_the_site_logo();
  78. }
  79. }
  80. /**
  81. * Custom function to check for a post thumbnail;
  82. * If Jetpack is not available, fall back to has_post_thumbnail()
  83. */
  84. function pique_has_post_thumbnail( $post = null ) {
  85. if ( function_exists( 'jetpack_has_featured_image' ) ) {
  86. return jetpack_has_featured_image( $post );
  87. } else {
  88. return has_post_thumbnail( $post );
  89. }
  90. }
  91. /**
  92. * Custom function to get the URL of a post thumbnail;
  93. * If Jetpack is not available, fall back to wp_get_attachment_image_src()
  94. */
  95. function pique_get_attachment_image_src( $post_id, $post_thumbnail_id, $size ) {
  96. if ( function_exists( 'jetpack_featured_images_fallback_get_image_src' ) ) {
  97. return jetpack_featured_images_fallback_get_image_src( $post_id, $post_thumbnail_id, $size );
  98. } else {
  99. $attachment = wp_get_attachment_image_src( $post_thumbnail_id, $size ); // Attachment array
  100. $url = $attachment[0]; // Attachment URL
  101. return $url;
  102. }
  103. }