sharing_display_extra

The Custom Tweaks for Jetpack by BarryCarlyon sharing display extra function.

Description

sharing_display_extra( (string) $text = '' ); 

Parameters (1)

0. $text — Optional. (string) => ''
The text.

Usage

  1. if ( !function_exists( 'sharing_display_extra' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'custom-tweaks-for-jetpack-by-barrycarlyon/modules/sharedaddy/sharing-display.php'; 
  3.  
  4. // The text. 
  5. $text = ''; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = sharing_display_extra($text); 
  9.  

Defined (1)

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

/modules/sharedaddy/sharing-display.php  
  1. function sharing_display_extra( $text = '' ) { 
  2. global $post, $wp_current_filter; 
  3.  
  4. if ( is_preview() ) { 
  5. return $text; 
  6.  
  7. if ( in_array( 'get_the_excerpt', (array) $wp_current_filter ) ) { 
  8. return $text; 
  9.  
  10. if ( is_attachment() && in_array( 'the_excerpt', (array) $wp_current_filter ) ) { 
  11. // Many themes run the_excerpt() conditionally on an attachment page, then run the_content(). 
  12. // We only want to output the sharing buttons once. Let's stick with the_content(). 
  13. return $text; 
  14.  
  15. $sharer = new Sharing_Service(); 
  16. $global = $sharer->get_global_options(); 
  17.  
  18. $show = false; 
  19. if ( !is_feed() ) { 
  20. if ( is_singular() && in_array( get_post_type(), $global['show'] ) ) { 
  21. $show = true; 
  22. } elseif ( in_array( 'index', $global['show'] ) && ( is_home() || is_archive() || is_search() ) ) { 
  23. $show = true; 
  24.  
  25. // Pass through a filter for final say so 
  26. $show = apply_filters( 'sharing_show', $show, $post ); 
  27.  
  28. // Disabled for this post? 
  29. $switched_status = get_post_meta( $post->ID, 'sharing_disabled', false ); 
  30.  
  31. if ( !empty( $switched_status ) ) 
  32. $show = false; 
  33.  
  34. // Allow to be used on P2 ajaxrequestsfor latest posts. 
  35. if ( defined( 'DOING_AJAX' ) && DOING_AJAX && isset( $_REQUEST['action'] ) && 'get_latest_posts' == $_REQUEST['action'] ) 
  36. $show = true; 
  37.  
  38. $sharing_content = ''; 
  39.  
  40. if ( $show ) { 
  41. $enabled = $sharer->get_blog_services(); 
  42.  
  43. if ( count( $enabled['all'] ) > 0 ) { 
  44. global $post; 
  45.  
  46. $dir = get_option( 'text_direction' ); 
  47.  
  48. // Wrapper 
  49. $sharing_content .= '<div class="sharedaddy sd-sharing-enabled"><div class="robots-nocontent sd-block sd-social sd-social-' . $global['button_style'] . ' sd-sharing">'; 
  50. if ( $global['sharing_label'] != '' ) 
  51. $sharing_content .= '<h3 class="sd-title">' . $global['sharing_label'] . '</h3>'; 
  52. $sharing_content .= '<div class="sd-content"><ul>'; 
  53.  
  54. // Visible items 
  55. $visible = ''; 
  56. foreach ( $enabled['visible'] as $id => $service ) { 
  57. // Individual HTML for sharing service 
  58. $visible .= '<li class="share-' . $service->get_class() . '">' . $service->get_display( $post ) . '</li>'; 
  59.  
  60. $parts = array(); 
  61. $parts[] = $visible; 
  62. if ( count( $enabled['hidden'] ) > 0 ) { 
  63. if ( count( $enabled['visible'] ) > 0 ) 
  64. $expand = __( 'More', 'jetpack' ); 
  65. else 
  66. $expand = __( 'Share', 'jetpack' ); 
  67. $parts[] = '<li><a href="#" class="sharing-anchor sd-button share-more"><span>'.$expand.'</span></a></li>'; 
  68.  
  69. if ( $dir == 'rtl' ) 
  70. $parts = array_reverse( $parts ); 
  71.  
  72. $sharing_content .= implode( '', $parts ); 
  73. $sharing_content .= '<li class="share-end"></li></ul>'; 
  74.  
  75. if ( count( $enabled['hidden'] ) > 0 ) { 
  76. $sharing_content .= '<div class="sharing-hidden"><div class="inner" style="display: none;'; 
  77.  
  78. if ( count( $enabled['hidden'] ) == 1 ) 
  79. $sharing_content .= 'width:150px;'; 
  80.  
  81. $sharing_content .= '">'; 
  82.  
  83. if ( count( $enabled['hidden'] ) == 1 ) 
  84. $sharing_content .= '<ul style="background-image:none;">'; 
  85. else 
  86. $sharing_content .= '<ul>'; 
  87.  
  88. $count = 1; 
  89. foreach ( $enabled['hidden'] as $id => $service ) { 
  90. // Individual HTML for sharing service 
  91. $sharing_content .= '<li class="share-'.$service->get_class().'">'; 
  92. $sharing_content .= $service->get_display( $post ); 
  93. $sharing_content .= '</li>'; 
  94.  
  95. if ( ( $count % 2 ) == 0 ) 
  96. $sharing_content .= '<li class="share-end"></li>'; 
  97.  
  98. $count ++; 
  99.  
  100. // End of wrapper 
  101. $sharing_content .= '<li class="share-end"></li></ul></div></div>'; 
  102.  
  103. $sharing_content .= '<div class="sharing-clear"></div></div></div></div>'; 
  104.  
  105. // Register our JS 
  106. wp_register_script( 'sharing-js', WP_SHARING_PLUGIN_URL.'sharing.js', array( 'jquery' ), '20120131' ); 
  107. add_action( 'wp_footer', 'sharing_add_footer' ); 
  108.  
  109. $options = get_option( 'jetpack_extras-options', array() ); 
  110. $option = ''; 
  111. if ( is_singular() || is_single() ) { 
  112. $option = isset($options['placement'][get_post_type()]) ? $options['placement'][get_post_type()] : 'below'; 
  113. } else { 
  114. $option = $options['placement']['index']; 
  115.  
  116. switch($option) { 
  117. case 'above': 
  118. return $sharing_content.$text; 
  119. case 'both': 
  120. return $sharing_content.$text.$sharing_content; 
  121. case 'below': 
  122. default: 
  123. return $text.$sharing_content;