jetpack.php 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. <?php
  2. /**
  3. * Jetpack Compatibility File.
  4. *
  5. * @link https://jetpack.me/
  6. *
  7. * @package Scratchpad
  8. */
  9. /**
  10. * Jetpack setup function.
  11. *
  12. * See: https://jetpack.me/support/infinite-scroll/
  13. * See: https://jetpack.me/support/responsive-videos/
  14. */
  15. function scratchpad_jetpack_setup() {
  16. // Add theme support for Infinite Scroll.
  17. add_theme_support( 'infinite-scroll', array(
  18. 'container' => 'main',
  19. 'render' => 'scratchpad_infinite_scroll_render',
  20. 'footer' => 'page',
  21. ) );
  22. // Add theme support for Responsive Videos.
  23. add_theme_support( 'jetpack-responsive-videos' );
  24. //Site logo
  25. add_image_size( 'scratchpad-site-logo', 800, 300 );
  26. add_theme_support( 'site-logo', array(
  27. 'size' => 'scratchpad-site-logo',
  28. ) );
  29. // Add theme support for Social Menus
  30. add_theme_support( 'jetpack-social-menu' );
  31. }
  32. add_action( 'after_setup_theme', 'scratchpad_jetpack_setup' );
  33. /**
  34. * Custom render function for Infinite Scroll.
  35. */
  36. function scratchpad_infinite_scroll_render() {
  37. $currentpost = get_option( 'posts_per_page' );
  38. while ( have_posts() ) {
  39. scratchpad_pieces( $currentpost );
  40. $currentpost++;
  41. the_post();
  42. if ( is_search() ) :
  43. get_template_part( 'template-parts/content', 'search' );
  44. else :
  45. get_template_part( 'template-parts/content', get_post_format() );
  46. endif;
  47. }
  48. }
  49. /*
  50. * Turn off infinite scroll if mobile + sidebar, or if footer widgets are active
  51. */
  52. if ( function_exists( 'jetpack_is_mobile' ) && ! function_exists( 'scratchpad_has_footer_widgets' ) ) {
  53. function scratchpad_has_footer_widgets() {
  54. if ( is_active_sidebar( 'sidebar-2' ) || ( ( jetpack_is_mobile( '', true ) && is_active_sidebar( 'sidebar-1' ) ) ) ) {
  55. return true;
  56. }
  57. return false;
  58. }
  59. } //endif
  60. add_filter( 'infinite_scroll_has_footer_widgets', 'scratchpad_has_footer_widgets' );
  61. /**
  62. * Return early if Site Logo is not available.
  63. */
  64. function scratchpad_the_site_logo() {
  65. if ( ! function_exists( 'jetpack_the_site_logo' ) ) {
  66. return;
  67. } else {
  68. jetpack_the_site_logo();
  69. }
  70. }
  71. function scratchpad_social_menu() {
  72. if ( ! function_exists( 'jetpack_social_menu' ) ) {
  73. return;
  74. } else {
  75. jetpack_social_menu();
  76. }
  77. }