Guest User

Untitled

a guest
Oct 8th, 2015
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.00 KB | None | 0 0
  1. function get_excerpt2($cut_at = '') {
  2.  
  3. global $post;
  4.  
  5. $continut=$post->post_content;
  6.  
  7. $pos=strpos($continut, '<!--more-->');
  8.  
  9.  
  10. if ($pos === false) {
  11.  
  12. //If the user supplied the excerpt in the post excerpt custom field, we just return that
  13. if ($this->post->post_excerpt != '') {
  14. return $this->post->post_excerpt;
  15. }
  16.  
  17. $buffy = '';
  18. if ($cut_at != '') {
  19. // simple, $cut_at and return
  20. $buffy .= td_util::excerpt($this->post->post_content, $cut_at);
  21. } else {
  22. $current_module_class = get_class($this);
  23.  
  24. //see if we have a default setting for this module, and if so only apply it if we don't get other things form theme panel.
  25. if (td_api_module::_check_excerpt_content($current_module_class)) {
  26. $db_content_excerpt = td_util::get_option($current_module_class . '_content_excerpt');
  27. if ($db_content_excerpt != '') {
  28. //cut from the database settings
  29. $buffy .= td_util::excerpt($this->post->post_content, $db_content_excerpt);
  30. } else {
  31. //cut at the default size
  32. $module_api = td_api_module::get_by_id($current_module_class);
  33. $buffy .= td_util::excerpt($this->post->post_content, $module_api['excerpt_content']);
  34. }
  35. } else {
  36. /**
  37. * no $cut_at provided and no setting in td_config -> return the full $this->post->post_content
  38. * @see td_global::$modules_list
  39. */
  40. $buffy .= $this->post->post_content;
  41. }
  42. }
  43. return $buffy;
  44. } else {
  45.  
  46.  
  47.  
  48. /* ----------------------------------------------------------------------------
  49. Prepare the content
  50. */
  51. $content = get_the_content(__td('Continue', TD_THEME_NAME));
  52. $content = apply_filters('the_content', $content);
  53. $content = str_replace(']]>', ']]&gt;', $content);
  54.  
  55.  
  56. /** ----------------------------------------------------------------------------
  57. * Smart list support. class_exists and new object WORK VIA AUTOLOAD
  58. * @see td_autoload_classes::loading_classes
  59. */
  60. //$td_smart_list = get_post_meta($this->post->ID, 'td_smart_list', true);
  61. $td_smart_list = get_post_meta($this->post->ID, 'td_post_theme_settings', true);
  62. if (!empty($td_smart_list['smart_list_template'])) {
  63.  
  64. $td_smart_list_class = $td_smart_list['smart_list_template'];
  65. if (class_exists($td_smart_list_class)) {
  66. /**
  67. * @var $td_smart_list_obj td_smart_list
  68. */
  69. $td_smart_list_obj = new $td_smart_list_class(); // make the class from string * magic :)
  70.  
  71. // prepare the settings for the smart list
  72. $smart_list_settings = array(
  73. 'post_content' => $content,
  74. 'counting_order_asc' => false,
  75. 'td_smart_list_h' => 'h3'
  76. );
  77.  
  78. if (!empty($td_smart_list['td_smart_list_order'])) {
  79. $smart_list_settings['counting_order_asc'] = true;
  80. }
  81.  
  82. if (!empty($td_smart_list['td_smart_list_h'])) {
  83. $smart_list_settings['td_smart_list_h'] = $td_smart_list['td_smart_list_h'];
  84. }
  85. return $td_smart_list_obj->render_from_post_content($smart_list_settings);
  86. } else {
  87. // there was an error?
  88. td_util::error(__FILE__, 'Missing smart list: ' . $td_smart_list_class . '. Did you disabled a tagDiv plugin?');
  89. }
  90. }
  91. /* ----------------------------------------------------------------------------
  92. end smart list - if we have a list, the function returns above
  93. */
  94.  
  95.  
  96. /* ----------------------------------------------------------------------------
  97. ad support on content
  98. */
  99.  
  100. //read the current ad settings
  101. $tds_inline_ad_paragraph = td_util::get_option('tds_inline_ad_paragraph');
  102. $tds_inline_ad_align = td_util::get_option('tds_inline_ad_align');
  103.  
  104.  
  105. //add the inline ad
  106. if (td_util::is_ad_spot_enabled('content_inline') and is_single()) {
  107.  
  108. if (empty($tds_inline_ad_paragraph)) {
  109. $tds_inline_ad_paragraph = 0;
  110. }
  111.  
  112. $cnt = 0;
  113. $content_buffer = ''; // we replace the content with this buffer at the end
  114.  
  115. $content_parts = preg_split('/(<p.*>)/U', $content, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
  116.  
  117. foreach ($content_parts as $content_part_index => $content_part_value) {
  118. if (!empty($content_part_value)) {
  119.  
  120. if ($tds_inline_ad_paragraph == ($content_part_index / 2)) {
  121. //it's time to show the ad
  122. switch ($tds_inline_ad_align) {
  123. case 'left':
  124. $content_buffer .= td_global_blocks::get_instance('td_block_ad_box')->render(array('spot_id' => 'content_inline', 'align' => 'left'));
  125. break;
  126.  
  127. case 'right':
  128. $content_buffer .= td_global_blocks::get_instance('td_block_ad_box')->render(array('spot_id' => 'content_inline', 'align' => 'right'));
  129. break;
  130.  
  131. default:
  132.  
  133. $content_buffer .= td_global_blocks::get_instance('td_block_ad_box')->render(array('spot_id' => 'content_inline'));
  134. break;
  135. }
  136. }
  137. $content_buffer .= $content_part_value;
  138. $cnt++;
  139. }
  140. }
  141. $content = $content_buffer;
  142. }
  143.  
  144. //add the top ad
  145. if (td_util::is_ad_spot_enabled('content_top') and is_single()) {
  146. $content = td_global_blocks::get_instance('td_block_ad_box')->render(array('spot_id' => 'content_top')) . $content;
  147. }
  148.  
  149.  
  150. //add bottom ad
  151. if (td_util::is_ad_spot_enabled('content_bottom') and is_single()) {
  152. $content = $content . td_global_blocks::get_instance('td_block_ad_box')->render(array('spot_id' => 'content_bottom'));
  153. }
  154.  
  155.  
  156. return $content;
  157.  
  158.  
  159.  
  160.  
  161.  
  162. }
  163.  
  164. }
Advertisement
Add Comment
Please, Sign In to add comment