Guest User

Untitled

a guest
Oct 18th, 2018
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 12.33 KB | None | 0 0
  1. <?php
  2. /**
  3. * Created by ra.
  4. * Date: 10/23/2015
  5. */
  6.  
  7. class td_module_single_mob extends td_module_single_base {
  8.  
  9. /*
  10. * display number of comments on post single page
  11. */
  12. function get_comments() {
  13. $buffy = '';
  14. if (td_util::get_option('tds_p_show_comments') != 'hide') {
  15. $buffy .= '<div class="td-post-comments">';
  16. $buffy .= '<a href="' . get_comments_link($this->post->ID) . '"><i class="td-icon-commenting"></i>';
  17. $buffy .= get_comments_number($this->post->ID);
  18. $buffy .= '</a>';
  19. $buffy .= '</div>';
  20. }
  21.  
  22. return $buffy;
  23. }
  24.  
  25.  
  26. /*
  27. * social share buttons - displayed on post single page at the top of the content
  28. */
  29. function get_social_sharing_top() {
  30. if (!$this->is_single) {
  31. return;
  32. }
  33.  
  34. if ((td_util::get_option('tds_top_social_show') == 'hide') and td_util::get_option('tds_top_like_show') != 'show'){
  35. return;
  36. }
  37.  
  38. $buffy = '';
  39.  
  40. // @todo single-post-thumbnail appears to not be in used! please check
  41. $image = wp_get_attachment_image_src( get_post_thumbnail_id( $this->post->ID ), 'single-post-thumbnail' );
  42.  
  43.  
  44. $buffy .= '<div class="td-post-sharing-top">';
  45. if( td_util::get_option('tds_top_like_show') == 'show' && td_util::is_amp() === false ) {
  46. $buffy .= '<div class="td-post-sharing-classic">';
  47. $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>';
  48. $buffy .= '</div>';
  49. }
  50.  
  51. if (td_util::get_option('tds_top_social_show') != 'hide') {
  52. $share_text_show = false;
  53. if (td_util::get_option('tds_top_like_share_text_show') == 'show') {
  54. $share_text_show = true;
  55. }
  56.  
  57. if ( td_util::is_amp() ) {
  58. $enabled_services = td_api_social_sharing_styles::_helper_get_enabled_socials();
  59. $amp_services = array_slice( $enabled_services, 0, 5);
  60.  
  61. $buffy .= td_social_sharing::render_generic(array(
  62. 'services' => $amp_services,
  63. 'style' => 'style1',
  64. 'share_text_show' => false,
  65. 'el_class' => ''
  66. ), 'td_social_sharing_article_top');
  67. } else {
  68. $buffy .= td_social_sharing::render_generic(array(
  69. 'services' => td_api_social_sharing_styles::_helper_get_enabled_socials(),
  70. 'style' => 'style1',
  71. 'share_text_show' => $share_text_show,
  72. 'el_class' => ''
  73. ), 'td_social_sharing_article_top');
  74. }
  75. }
  76. $buffy .= '</div>';
  77.  
  78.  
  79. return $buffy;
  80. }
  81.  
  82. /*
  83. * social share buttons - displayed on post single page at the bottom of the content
  84. */
  85. function get_social_sharing_bottom() {
  86. if (!$this->is_single) {
  87. return;
  88. }
  89.  
  90. if ((td_util::get_option('tds_top_social_show') == 'hide') and td_util::get_option('tds_top_like_show') != 'show'){
  91. return;
  92. }
  93.  
  94. $buffy = '';
  95. // @todo single-post-thumbnail appears to not be in used! please check
  96. $image = wp_get_attachment_image_src( get_post_thumbnail_id( $this->post->ID ), 'single-post-thumbnail' );
  97.  
  98. $buffy .= '<div class="td-post-sharing-bottom">';
  99. if( td_util::get_option('tds_bottom_like_show') != 'hide' && td_util::is_amp() === false ) {
  100. $buffy .= '<div class="td-post-sharing-classic">';
  101. $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>';
  102. $buffy .= '</div>';
  103. }
  104.  
  105. if (td_util::get_option('tds_bottom_social_show') != 'hide') {
  106. $share_text_show = false;
  107. if (td_util::get_option('tds_bottom_like_share_text_show') == 'show') {
  108. $share_text_show = true;
  109. }
  110.  
  111. if ( td_util::is_amp() ) {
  112. $enabled_services = td_api_social_sharing_styles::_helper_get_enabled_socials();
  113. $amp_services = array_slice( $enabled_services, 0, 5);
  114.  
  115. $buffy .= td_social_sharing::render_generic(array(
  116. 'services' => $amp_services,
  117. 'style' => 'style1',
  118. 'share_text_show' => false,
  119. 'el_class' => ''
  120. ), 'td_social_sharing_article_bottom');
  121. } else {
  122. $buffy .= td_social_sharing::render_generic(array(
  123. 'services' => td_api_social_sharing_styles::_helper_get_enabled_socials(),
  124. 'style' => 'style1',
  125. 'share_text_show' => $share_text_show,
  126. 'el_class' => ''
  127. ), 'td_social_sharing_article_bottom');
  128. }
  129. }
  130. $buffy .= '</div>';
  131.  
  132. return $buffy;
  133. }
  134.  
  135.  
  136. /**
  137. * gets the related posts ONLY on single posts. Does not run on custom post types because we don't know what taxonomy to choose and the
  138. * blocks do not support custom taxonomies as of 15 july 2015
  139. *
  140. * $force_sidebar_position - not used on mobile theme
  141. *
  142. * @return string
  143. */
  144. function related_posts($force_sidebar_position = '') {
  145. global $post;
  146. if ($post->post_type != 'post') {
  147. return '';
  148. }
  149.  
  150. if (td_util::get_option('tds_similar_articles') == 'hide') {
  151. return '';
  152. }
  153.  
  154. //td_global::$cur_single_template_sidebar_pos;
  155.  
  156. //cur_post_same_tags
  157. //cur_post_same_author
  158. //cur_post_same_categories
  159.  
  160. if (td_util::get_option('tds_similar_articles_type') == 'by_tag') {
  161. $td_related_ajax_filter_type = 'cur_post_same_tags';
  162. } else {
  163. $td_related_ajax_filter_type = 'cur_post_same_categories';
  164. }
  165.  
  166. // the number of rows to show. this number will be multiplied with the hardcoded limit
  167. $tds_similar_articles_rows = td_util::get_option('tds_similar_articles_rows');
  168. if (empty($tds_similar_articles_rows)) {
  169. $tds_similar_articles_rows = 1;
  170. }
  171.  
  172. $td_related_limit = 3 * $tds_similar_articles_rows;
  173.  
  174.  
  175. /**
  176. * 'td_ajax_filter_type' => 'td_custom_related' - this ajax filter type overwrites the live filter via ajax @see td_ajax::on_ajax_block
  177. */
  178. $td_block_args = array (
  179. 'limit' => $td_related_limit,
  180. 'ajax_pagination' => 'next_prev',
  181. 'live_filter' => $td_related_ajax_filter_type, //live atts - this is the default setting for this block
  182. 'td_ajax_filter_type' => 'td_custom_related' //this filter type can overwrite the live filter @see
  183. );
  184.  
  185. /**
  186. * @see td_block_related_posts
  187. */
  188.  
  189. return td_global_blocks::get_instance('td_block_related_posts_mob')->render($td_block_args);
  190.  
  191. }
  192.  
  193.  
  194. /**
  195. * the content of a single post or single post type
  196. * @return mixed|string|void
  197. */
  198. function get_content() {
  199.  
  200. /* ----------------------------------------------------------------------------
  201. Prepare the content
  202. */
  203. $content = get_the_content(__td('Continue', TD_THEME_NAME));
  204. $content = apply_filters('the_content', $content);
  205. $content = str_replace(']]>', ']]&gt;', $content);
  206.  
  207.  
  208.  
  209. /** ----------------------------------------------------------------------------
  210. * Smart list support. class_exists and new object WORK VIA AUTOLOAD
  211. * @see td_autoload_classes::loading_classes
  212. */
  213. //$td_smart_list = get_post_meta($this->post->ID, 'td_smart_list', true);
  214. $td_smart_list = td_util::get_post_meta_array($this->post->ID, 'td_post_theme_settings');
  215. if (!empty($td_smart_list['smart_list_template'])) {
  216.  
  217. $td_smart_list_class = 'td_smart_list_mob_1';
  218. if (class_exists($td_smart_list_class)) {
  219. /**
  220. * @var $td_smart_list_obj td_smart_list
  221. */
  222. $td_smart_list_obj = new $td_smart_list_class(); // make the class from string * magic :)
  223.  
  224. // prepare the settings for the smart list
  225. $smart_list_settings = array(
  226. 'post_content' => $content,
  227. 'counting_order_asc' => false,
  228. 'td_smart_list_h' => 'h3',
  229. 'extract_first_image' => td_api_smart_list::get_key($td_smart_list_class, 'extract_first_image')
  230. );
  231.  
  232. if (!empty($td_smart_list['td_smart_list_order'])) {
  233. $smart_list_settings['counting_order_asc'] = true;
  234. }
  235.  
  236. if (!empty($td_smart_list['td_smart_list_h'])) {
  237. $smart_list_settings['td_smart_list_h'] = $td_smart_list['td_smart_list_h'];
  238. }
  239. return $td_smart_list_obj->render_from_post_content($smart_list_settings);
  240. } else {
  241. // there was an error?
  242. td_util::error(__FILE__, 'Missing smart list: ' . $td_smart_list_class . '. Did you disabled a tagDiv plugin?');
  243. }
  244. }
  245. /* ----------------------------------------------------------------------------
  246. end smart list - if we have a list, the function returns above
  247. */
  248.  
  249.  
  250.  
  251.  
  252. /* ----------------------------------------------------------------------------
  253. ad support on content
  254. */
  255.  
  256. //read the current ad settings
  257. $tds_inline_ad_paragraph_mob = td_util::get_option('tds_inline_ad_paragraph_mob');
  258.  
  259. // add inline ad
  260. if ( is_single() ) {
  261.  
  262. if (empty($tds_inline_ad_paragraph_mob)) {
  263. $tds_inline_ad_paragraph_mob = 0;
  264. }
  265.  
  266. $cnt = 0;
  267. $content_buffer = ''; // we replace the content with this buffer at the end
  268.  
  269. $content_parts = preg_split('/(<p.*>)/U', $content, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
  270.  
  271. $p_open_tag_count = 0; // count how many <p> tags we have added to the buffer
  272.  
  273. foreach ($content_parts as $content_part_index => $content_part_value) {
  274. if (!empty($content_part_value)) {
  275.  
  276. // Show the ad ONLY IF THE CURRENT PART IS A <p> opening tag and before the <p> -> so we will have <p>content</p> ~ad~ <p>content</p>
  277. // and prevent cases like <p> ~ad~ content</p>
  278. if (preg_match('/(<p.*>)/U', $content_part_value) === 1) {
  279. if ($tds_inline_ad_paragraph_mob == $p_open_tag_count) {
  280.  
  281. $content_buffer .= td_global_blocks::get_instance('td_block_ad_box_mob')->render(array('spot_id' => 'content_inline_mob'));
  282. }
  283. $p_open_tag_count++;
  284.  
  285. }
  286. $content_buffer .= $content_part_value;
  287. $cnt++;
  288.  
  289. }
  290.  
  291. }
  292. $content = $content_buffer;
  293. }
  294.  
  295.  
  296. // add top ad
  297. if ( is_single() ) {
  298. $content = td_global_blocks::get_instance('td_block_ad_box_mob')->render(array('spot_id' => 'content_top_mob')) . $content;
  299. }
  300.  
  301.  
  302. //add bottom ad
  303. if ( is_single() ) {
  304. $content = $content . td_global_blocks::get_instance('td_block_ad_box_mob')->render(array('spot_id' => 'content_bottom_mob'));
  305. }
  306.  
  307.  
  308. return $content;
  309. }
  310.  
  311. }
Advertisement
Add Comment
Please, Sign In to add comment