jetpack.php 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. <?php
  2. /**
  3. * Jetpack Compatibility File
  4. * See: https://jetpack.me/
  5. *
  6. * @package Libre 2
  7. */
  8. /**
  9. * Add theme support for Infinite Scroll.
  10. * See: https://jetpack.me/support/infinite-scroll/
  11. */
  12. function libre_2_jetpack_setup() {
  13. add_theme_support( 'infinite-scroll', array(
  14. 'container' => 'main',
  15. 'render' => 'libre_2_infinite_scroll_render',
  16. 'footer' => 'masthead',
  17. 'footer_widgets' => array( 'sidebar-2', 'sidebar-3', 'sidebar-4' ),
  18. 'wrapper' => false,
  19. ) );
  20. add_theme_support( 'jetpack-responsive-videos' );
  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' => 'libre-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, // enable or not the featured image check for archive pages: true or false
  34. 'post' => true, // enable or not the featured image check for single posts: true or false
  35. 'page' => true, // enable or not the featured image check for single pages: true or false
  36. 'fallback' => true,
  37. 'fallback-default' => false,
  38. ),
  39. ) );
  40. } // end function libre_2_jetpack_setup
  41. add_action( 'after_setup_theme', 'libre_2_jetpack_setup' );
  42. /**
  43. * Custom render function for Infinite Scroll.
  44. */
  45. function libre_2_infinite_scroll_render() {
  46. if ( class_exists( 'WooCommerce' ) && ( libre_2_woocommerce_is_shop_page() || is_product_taxonomy() || is_product_category() || is_product_tag() ) ) {
  47. libre_2_woocommerce_product_columns_wrapper();
  48. woocommerce_product_loop_start();
  49. }
  50. while ( have_posts() ) {
  51. the_post();
  52. if ( is_search() ) :
  53. get_template_part( 'template-parts/content', 'search' );
  54. elseif ( class_exists( 'WooCommerce' ) && ( libre_2_woocommerce_is_shop_page() || is_product_taxonomy() || is_product_category() || is_product_tag() ) ) :
  55. wc_get_template_part( 'content', 'product' );
  56. else :
  57. get_template_part( 'template-parts/content', get_post_format() );
  58. endif;
  59. }
  60. if ( class_exists( 'WooCommerce' ) && ( libre_2_woocommerce_is_shop_page() || is_product_taxonomy() || is_product_category() || is_product_tag() ) ) {
  61. woocommerce_product_loop_end();
  62. libre_2_woocommerce_product_columns_wrapper_close();
  63. }
  64. } // end function libre_2_infinite_scroll_render
  65. /**
  66. * Return early if Social Menu is not available.
  67. */
  68. function libre_2_social_menu() {
  69. if ( ! function_exists( 'jetpack_social_menu' ) ) {
  70. return;
  71. } else {
  72. jetpack_social_menu();
  73. }
  74. }
  75. /**
  76. * Return early if Author Bio is not available.
  77. */
  78. function libre_2_author_bio() {
  79. if ( ! function_exists( 'jetpack_author_bio' ) ) {
  80. get_template_part( 'template-parts/content', 'author' );
  81. } else {
  82. jetpack_author_bio();
  83. }
  84. }
  85. /**
  86. * Author Bio Avatar Size.
  87. */
  88. function libre_2_author_bio_avatar_size() {
  89. return 100;
  90. }
  91. add_filter( 'jetpack_author_bio_avatar_size', 'libre_2_author_bio_avatar_size' );
  92. /**
  93. * Custom function to check for a post thumbnail;
  94. * If Jetpack is not available, fall back to has_post_thumbnail()
  95. */
  96. function libre_2_has_post_thumbnail( $post = null ) {
  97. if ( function_exists( 'jetpack_has_featured_image' ) ) {
  98. return jetpack_has_featured_image( $post );
  99. } else {
  100. return has_post_thumbnail( $post );
  101. }
  102. }