jetpack.php 3.3 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. 'archive-default' => false, // the default setting of the featured image on archive pages, if it's enabled or not: true or false
  35. 'post' => true, // enable or not the featured image check for single posts: true or false
  36. 'page' => true, // enable or not the featured image check for single pages: true or false
  37. 'fallback' => true,
  38. 'fallback-default' => false,
  39. ),
  40. ) );
  41. } // end function libre_2_jetpack_setup
  42. add_action( 'after_setup_theme', 'libre_2_jetpack_setup' );
  43. /**
  44. * Custom render function for Infinite Scroll.
  45. */
  46. function libre_2_infinite_scroll_render() {
  47. if ( class_exists( 'WooCommerce' ) && ( is_shop() || is_product_taxonomy() || is_product_category() || is_product_tag() ) ) {
  48. libre_2_woocommerce_product_columns_wrapper();
  49. woocommerce_product_loop_start();
  50. }
  51. while ( have_posts() ) {
  52. the_post();
  53. if ( class_exists( 'WooCommerce' ) && ( is_shop() || is_product_taxonomy() || is_product_category() || is_product_tag() ) ) :
  54. wc_get_template_part( 'content', 'product' );
  55. else :
  56. get_template_part( 'template-parts/content', get_post_format() );
  57. endif;
  58. }
  59. if ( class_exists( 'WooCommerce' ) && ( is_shop() || is_product_taxonomy() || is_product_category() || is_product_tag() ) ) {
  60. woocommerce_product_loop_end();
  61. libre_2_woocommerce_product_columns_wrapper_close();
  62. }
  63. } // end function libre_2_infinite_scroll_render
  64. /**
  65. * Return early if Social Menu is not available.
  66. */
  67. function libre_2_social_menu() {
  68. if ( ! function_exists( 'jetpack_social_menu' ) ) {
  69. return;
  70. } else {
  71. jetpack_social_menu();
  72. }
  73. }
  74. /**
  75. * Return early if Author Bio is not available.
  76. */
  77. function libre_2_author_bio() {
  78. if ( ! function_exists( 'jetpack_author_bio' ) ) {
  79. get_template_part( 'template-parts/content', 'author' );
  80. } else {
  81. jetpack_author_bio();
  82. }
  83. }
  84. /**
  85. * Author Bio Avatar Size.
  86. */
  87. function libre_2_author_bio_avatar_size() {
  88. return 100;
  89. }
  90. add_filter( 'jetpack_author_bio_avatar_size', 'libre_2_author_bio_avatar_size' );
  91. /**
  92. * Custom function to check for a post thumbnail;
  93. * If Jetpack is not available, fall back to has_post_thumbnail()
  94. */
  95. function libre_2_has_post_thumbnail( $post = null ) {
  96. if ( function_exists( 'jetpack_has_featured_image' ) ) {
  97. return jetpack_has_featured_image( $post );
  98. } else {
  99. return has_post_thumbnail( $post );
  100. }
  101. }