sharing_add_footer

The Jetpack by WordPress.com sharing add footer function.

Description

sharing_add_footer(); 

Usage

  1. if ( !function_exists( 'sharing_add_footer' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'jetpack-by-wordpress-com/modules/sharedaddy/sharing-service.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = sharing_add_footer(); 
  7.  

Defined (1)

The function is defined in the following location(s).

/modules/sharedaddy/sharing-service.php  
  1. function sharing_add_footer() { 
  2. global $jetpack_sharing_counts; 
  3.  
  4. /** 
  5. * Filter all Javascript output by the sharing module. 
  6. * @module sharedaddy 
  7. * @since 1.1.0 
  8. * @param bool true Control whether the sharing module should add any Javascript to the site. Default to true. 
  9. */ 
  10. if ( apply_filters( 'sharing_js', true ) && sharing_maybe_enqueue_scripts() ) { 
  11.  
  12. /** 
  13. * Filter the display of sharing counts next to the sharing buttons. 
  14. * @module sharedaddy 
  15. * @since 3.2.0 
  16. * @param bool true Control the display of counters next to the sharing buttons. Default to true. 
  17. */ 
  18. if ( apply_filters( 'jetpack_sharing_counts', true ) && is_array( $jetpack_sharing_counts ) && count( $jetpack_sharing_counts ) ) : 
  19. $sharing_post_urls = array_filter( $jetpack_sharing_counts ); 
  20. if ( $sharing_post_urls ) : 
  21. ?> 
  22.  
  23. <script type="text/javascript"> 
  24. window.WPCOM_sharing_counts = <?php echo json_encode( array_flip( $sharing_post_urls ) ); ?>; 
  25. </script> 
  26. <?php 
  27. endif; 
  28. endif; 
  29.  
  30. wp_enqueue_script( 'sharing-js' ); 
  31. $sharing_js_options = array( 
  32. /** This filter is documented in modules/sharedaddy/sharing-service.php */ 
  33. 'counts' => apply_filters( 'jetpack_sharing_counts', true ) 
  34. ); 
  35. wp_localize_script( 'sharing-js', 'sharing_js_options', $sharing_js_options); 
  36.  
  37. $sharer = new Sharing_Service(); 
  38. $enabled = $sharer->get_blog_services(); 
  39. foreach ( array_merge( $enabled['visible'], $enabled['hidden'] ) AS $service ) { 
  40. $service->display_footer();