Guest User

Untitled

a guest
Aug 3rd, 2016
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.98 KB | None | 0 0
  1. <?php
  2.  
  3. /**
  4. * Class td_module_single
  5. */
  6.  
  7. class td_module_single extends td_module_single_base {
  8.  
  9. function get_social_sharing_top() {
  10. if (!$this->is_single) {
  11. return;
  12. }
  13.  
  14. if (td_util::get_option('tds_top_social_show') == 'hide' and td_util::get_option('tds_top_like_tweet_show') != 'show') {
  15. return;
  16. }
  17.  
  18. // used to style the sharing icon to be big on tablet
  19. $td_no_like = '';
  20. if (td_util::get_option('tds_top_like_tweet_show') == 'show') {
  21. $td_no_like = 'td-with-like';
  22. }
  23.  
  24. $buffy = '';
  25.  
  26. // @todo single-post-thumbnail appears to not be in used! please check
  27. $image = wp_get_attachment_image_src( get_post_thumbnail_id( $this->post->ID ), 'single-post-thumbnail' );
  28.  
  29. $twitter_user = td_util::get_option('tds_tweeter_username');
  30.  
  31.  
  32. $buffy .= '<div class="td-post-sharing td-post-sharing-top ' . $td_no_like . '">';
  33.  
  34. if (td_util::get_option('tds_top_social_show') != 'hide') {
  35.  
  36. /**
  37. * get Pinterest share description
  38. * get it from SEO by Yoast meta (if the plugin is active and the description is set) else use the post title
  39. */
  40. if (is_plugin_active('wordpress-seo/wp-seo.php') and get_post_meta($this->post->ID, '_yoast_wpseo_metadesc', true) != '') {
  41. $td_pinterest_share_description = get_post_meta($this->post->ID, '_yoast_wpseo_metadesc', true);
  42. } else{
  43. $td_pinterest_share_description = htmlspecialchars(urlencode(html_entity_decode($this->title, ENT_COMPAT, 'UTF-8')), ENT_COMPAT, 'UTF-8');
  44. }
  45.  
  46. $buffy .= '
  47. <div class="td-default-sharing">
  48. <a class="td-social-sharing-buttons td-social-facebook" href="http://www.facebook.com/sharer.php?u=' . urlencode( esc_url( get_permalink() ) ) . '" onclick="window.open(this.href, \'mywin\',\'left=50,top=50,width=600,height=350,toolbar=0\'); return false;"><i class="td-icon-facebook"></i><div class="td-social-but-text">' . __td('Share on Facebook', TD_THEME_NAME) . '</div></a>
  49. <a class="td-social-sharing-buttons td-social-twitter" href="https://twitter.com/intent/tweet?text=' . htmlspecialchars(urlencode(html_entity_decode($this->title, ENT_COMPAT, 'UTF-8')), ENT_COMPAT, 'UTF-8') . '&url=' . esc_url( get_permalink() ) . '&via=' . urlencode( $twitter_user ? $twitter_user : get_bloginfo( 'name' ) ) . '" ><i class="td-icon-twitter"></i><div class="td-social-but-text">' . __td('Tweet on Twitter', TD_THEME_NAME) . '</div></a>
  50. <a class="td-social-sharing-buttons td-social-google" href="http://plus.google.com/share?url=' . esc_url( get_permalink() ) . '" onclick="window.open(this.href, \'mywin\',\'left=50,top=50,width=600,height=350,toolbar=0\'); return false;"><i class="td-icon-googleplus"></i></a>
  51. <a class="td-social-sharing-buttons td-social-pinterest" href="http://pinterest.com/pin/create/button/?url=' . esc_url( get_permalink() ) . '&amp;media=' . ( ! empty( $image[0] ) ? $image[0] : '' ) . '&description=' . $td_pinterest_share_description . '" onclick="window.open(this.href, \'mywin\',\'left=50,top=50,width=600,height=350,toolbar=0\'); return false;"><i class="td-icon-pinterest"></i></a>
  52. <a class="td-social-sharing-buttons td-social-whatsapp" href="whatsapp://send?text=' . htmlspecialchars(urlencode(html_entity_decode($this->title, ENT_COMPAT, 'UTF-8')), ENT_COMPAT, 'UTF-8') . '%20-%20' . urlencode( esc_url( get_permalink() ) ) . '" ><i class="td-icon-whatsapp"></i></a>
  53. </div>';
  54. }
  55.  
  56.  
  57. if (td_util::get_option('tds_top_like_tweet_show') == 'show') {
  58. //classic share buttons
  59. $buffy .= '<div class="td-classic-sharing">';
  60. $buffy .= '<ul>';
  61.  
  62. $buffy .= '<li class="td-classic-facebook">';
  63. $buffy .= '<iframe frameBorder="0" src="' . td_global::$http_or_https . '://www.facebook.com/plugins/like.php?href=' . $this->href . '&amp;layout=button_count&amp;show_faces=false&amp;width=105&amp;action=like&amp;colorscheme=light&amp;height=21" style="border:none; overflow:hidden; width:105px; height:21px; background-color:transparent;"></iframe>';
  64. $buffy .= '</li>';
  65.  
  66. $buffy .= '<li class="td-classic-twitter">';
  67. $buffy .= '<a href="https://twitter.com/share" class="twitter-share-button" data-url="' . esc_attr($this->href) . '" data-text="' . $this->title . '" data-via="' . td_util::get_option('tds_' . 'social_twitter') . '" data-lang="en">tweet</a> <script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>';
  68. $buffy .= '</li>';
  69.  
  70. $buffy .= '</ul>';
  71. $buffy .= '</div>';
  72. }
  73.  
  74. $buffy .= '</div>';
  75.  
  76. return $buffy;
  77. }
  78.  
  79.  
  80. function get_social_sharing_bottom() {
  81. if (!$this->is_single) {
  82. return;
  83. }
  84.  
  85. if (td_util::get_option('tds_bottom_social_show') == 'hide' and td_util::get_option('tds_bottom_like_tweet_show') == 'hide') {
  86. return;
  87. }
  88.  
  89. // used to style the sharing icon to be big on tablet
  90. $td_no_like = '';
  91. if (td_util::get_option('tds_bottom_like_tweet_show') != 'hide') {
  92. $td_no_like = 'td-with-like';
  93. }
  94.  
  95. $buffy = '';
  96. // @todo single-post-thumbnail appears to not be in used! please check
  97. $image = wp_get_attachment_image_src( get_post_thumbnail_id( $this->post->ID ), 'single-post-thumbnail' );
  98. $buffy .= '<div class="td-post-sharing td-post-sharing-bottom ' . $td_no_like . '"><span class="td-post-share-title">' . __td('SHARE', TD_THEME_NAME) . '</span>';
  99.  
  100.  
  101. if (td_util::get_option('tds_bottom_social_show') != 'hide') {
  102. $twitter_user = td_util::get_option( 'tds_tweeter_username' );
  103.  
  104. /**
  105. * get Pinterest share description
  106. * get it from SEO by Yoast meta (if the plugin is active and the description is set) else use the post title
  107. */
  108. if (is_plugin_active('wordpress-seo/wp-seo.php') and get_post_meta($this->post->ID, '_yoast_wpseo_metadesc', true) != '') {
  109. $td_pinterest_share_description = get_post_meta($this->post->ID, '_yoast_wpseo_metadesc', true);
  110. } else{
  111. $td_pinterest_share_description = htmlspecialchars(urlencode(html_entity_decode($this->title, ENT_COMPAT, 'UTF-8')), ENT_COMPAT, 'UTF-8');
  112. }
  113.  
  114. //default share buttons
  115. $buffy .= '
  116. <div class="td-default-sharing">
  117. <a class="td-social-sharing-buttons td-social-facebook" href="http://www.facebook.com/sharer.php?u=' . urlencode( esc_url( get_permalink() ) ) . '" onclick="window.open(this.href, \'mywin\',\'left=50,top=50,width=600,height=350,toolbar=0\'); return false;"><i class="td-icon-facebook"></i><div class="td-social-but-text">Facebook</div></a>
  118. <a class="td-social-sharing-buttons td-social-twitter" href="https://twitter.com/intent/tweet?text=' . htmlspecialchars(urlencode(html_entity_decode($this->title, ENT_COMPAT, 'UTF-8')), ENT_COMPAT, 'UTF-8') . '&url=' . esc_url( get_permalink() ) . '&via=' . urlencode( $twitter_user ? $twitter_user : get_bloginfo( 'name' ) ) . '"><i class="td-icon-twitter"></i><div class="td-social-but-text">Twitter</div></a>
  119. <a class="td-social-sharing-buttons td-social-google" href="http://plus.google.com/share?url=' . esc_url( get_permalink() ) . '" onclick="window.open(this.href, \'mywin\',\'left=50,top=50,width=600,height=350,toolbar=0\'); return false;"><i class="td-icon-googleplus"></i></a>
  120. <a class="td-social-sharing-buttons td-social-pinterest" href="http://pinterest.com/pin/create/button/?url=' . esc_url( get_permalink() ) . '&amp;media=' . ( ! empty( $image[0] ) ? $image[0] : '' ) . '&description=' . $td_pinterest_share_description . '" onclick="window.open(this.href, \'mywin\',\'left=50,top=50,width=600,height=350,toolbar=0\'); return false;"><i class="td-icon-pinterest"></i></a>
  121. <a class="td-social-sharing-buttons td-social-whatsapp" href="whatsapp://send?text=' . htmlspecialchars(urlencode(html_entity_decode($this->title, ENT_COMPAT, 'UTF-8')), ENT_COMPAT, 'UTF-8') . '%20-%20' . urlencode( esc_url( get_permalink() ) ) . '" ><i class="td-icon-whatsapp"></i></a>
  122. </div>';
  123. }
  124.  
  125.  
  126. if (td_util::get_option('tds_bottom_like_tweet_show') != 'hide') {
  127. //classic share buttons
  128. $buffy .= '<div class="td-classic-sharing">';
  129. $buffy .= '<ul>';
  130.  
  131. $buffy .= '<li class="td-classic-facebook">';
  132. $buffy .= '<iframe frameBorder="0" src="' . td_global::$http_or_https . '://www.facebook.com/plugins/like.php?href=' . $this->href . '&amp;layout=button_count&amp;show_faces=false&amp;width=105&amp;action=like&amp;colorscheme=light&amp;height=21" style="border:none; overflow:hidden; width:105px; height:21px; background-color:transparent;"></iframe>';
  133. $buffy .= '</li>';
  134.  
  135. $buffy .= '<li class="td-classic-twitter">';
  136. $buffy .= '<a href="https://twitter.com/share" class="twitter-share-button" data-url="' . esc_attr($this->href) . '" data-text="' . $this->title . '" data-via="' . td_util::get_option('tds_' . 'social_twitter') . '" data-lang="en">tweet</a> <script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>';
  137. $buffy .= '</li>';
  138.  
  139. $buffy .= '</ul>';
  140. $buffy .= '</div>';
  141. }
  142.  
  143.  
  144.  
  145.  
  146.  
  147. $buffy .= '</div>';
  148.  
  149. return $buffy;
  150. }
  151.  
  152.  
  153.  
  154.  
  155.  
  156.  
  157. }
Advertisement
Add Comment
Please, Sign In to add comment