jetpack.php 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. <?php
  2. /**
  3. * Jetpack Compatibility File
  4. * See: http://jetpack.me/
  5. *
  6. * @package Intergalactic 2
  7. */
  8. /**
  9. * Add theme support for Infinite Scroll.
  10. * See: http://jetpack.me/support/infinite-scroll/
  11. */
  12. function intergalactic_2_jetpack_setup() {
  13. add_theme_support( 'infinite-scroll', array(
  14. 'container' => 'main',
  15. 'footer' => 'page',
  16. 'render' => 'intergalatic_infinite_scroll_render',
  17. 'footer_widgets' => array( 'sidebar-2', 'sidebar-3', 'sidebar-4' ),
  18. ) );
  19. //Add theme support for Content Options.
  20. add_theme_support( 'jetpack-content-options', array(
  21. 'blog-display' => false,
  22. 'author-bio' => true,
  23. 'post-details' => array(
  24. 'stylesheet' => 'intergalactic-2-style',
  25. 'date' => '.posted-on',
  26. 'categories' => '.entry-categories',
  27. 'tags' => '.entry-tags',
  28. 'author' => '.byline',
  29. ),
  30. 'featured-images' => array(
  31. 'archive' => true, // enable or not the featured image check for archive pages: true or false
  32. 'post' => true, // enable or not the featured image check for single posts: true or false
  33. 'page' => true, // enable or not the featured image check for single pages: true or false
  34. 'fallback' => true,
  35. ),
  36. ) );
  37. add_theme_support( 'jetpack-social-menu', 'svg' );
  38. add_theme_support( 'jetpack-responsive-videos' );
  39. }
  40. add_action( 'after_setup_theme', 'intergalactic_2_jetpack_setup' );
  41. if ( ! function_exists( 'intergalatic_infinite_scroll_render' ) ) {
  42. function intergalatic_infinite_scroll_render() {
  43. while( have_posts() ) {
  44. the_post();
  45. get_template_part( 'content', 'home' );
  46. }
  47. }
  48. }
  49. /**
  50. * Return early if Social Menu is not available.
  51. */
  52. function intergalactic_2_social_menu() {
  53. if ( ! function_exists( 'jetpack_social_menu' ) ) {
  54. return;
  55. } else {
  56. jetpack_social_menu();
  57. }
  58. }
  59. /**
  60. * Return early if Author Bio is not available.
  61. */
  62. function intergalactic_2_author_bio() {
  63. if ( ! function_exists( 'jetpack_author_bio' ) ) {
  64. get_template_part( 'content', 'author' );
  65. } else {
  66. jetpack_author_bio();
  67. }
  68. }
  69. /**
  70. * Author Bio Avatar Size.
  71. */
  72. function intergalactic_2_author_bio_avatar_size() {
  73. return 140;
  74. }
  75. add_filter( 'jetpack_author_bio_avatar_size', 'intergalactic_2_author_bio_avatar_size' );
  76. /**
  77. * Show/Hide Featured Image outside of the loop.
  78. */
  79. function intergalactic_2_jetpack_featured_image_display() {
  80. if ( ! function_exists( 'jetpack_featured_images_remove_post_thumbnail' ) ) {
  81. return true;
  82. } else {
  83. $options = get_theme_support( 'jetpack-content-options' );
  84. $featured_images = ( ! empty( $options[0]['featured-images'] ) ) ? $options[0]['featured-images'] : null;
  85. $settings = array(
  86. 'post-default' => ( isset( $featured_images['post-default'] ) && false === $featured_images['post-default'] ) ? '' : 1,
  87. 'page-default' => ( isset( $featured_images['page-default'] ) && false === $featured_images['page-default'] ) ? '' : 1,
  88. );
  89. $settings = array_merge( $settings, array(
  90. 'post-option' => get_option( 'jetpack_content_featured_images_post', $settings['post-default'] ),
  91. 'page-option' => get_option( 'jetpack_content_featured_images_page', $settings['page-default'] ),
  92. ) );
  93. if (
  94. ( ! $settings['post-option'] && is_single() )
  95. || ( ! $settings['page-option'] && is_singular() && is_page() )
  96. ) {
  97. return false;
  98. } else {
  99. return true;
  100. }
  101. }
  102. }
  103. /**
  104. * Custom function to check for a post thumbnail;
  105. * If Jetpack is not available, fall back to has_post_thumbnail()
  106. */
  107. function intergalactic_2_has_post_thumbnail( $post = null ) {
  108. if ( function_exists( 'jetpack_has_featured_image' ) ) {
  109. return jetpack_has_featured_image( $post );
  110. } else {
  111. return has_post_thumbnail( $post );
  112. }
  113. }
  114. /**
  115. * Custom function to get the URL of a post thumbnail;
  116. * If Jetpack is not available, fall back to wp_get_attachment_image_src()
  117. */
  118. function intergalactic_2_get_attachment_image_src( $post_id, $post_thumbnail_id, $size ) {
  119. if ( function_exists( 'jetpack_featured_images_fallback_get_image_src' ) ) {
  120. return jetpack_featured_images_fallback_get_image_src( $post_id, $post_thumbnail_id, $size );
  121. } else {
  122. $attachment = wp_get_attachment_image_src( $post_thumbnail_id, $size ); // Attachment array
  123. $url = $attachment[0]; // Attachment URL
  124. return $url;
  125. }
  126. }