Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function get_excerpt2($cut_at = '') {
- global $post;
- $continut=$post->post_content;
- $pos=strpos($continut, '<!--more-->');
- if ($pos === false) {
- //If the user supplied the excerpt in the post excerpt custom field, we just return that
- if ($this->post->post_excerpt != '') {
- return $this->post->post_excerpt;
- }
- $buffy = '';
- if ($cut_at != '') {
- // simple, $cut_at and return
- $buffy .= td_util::excerpt($this->post->post_content, $cut_at);
- } else {
- $current_module_class = get_class($this);
- //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.
- if (td_api_module::_check_excerpt_content($current_module_class)) {
- $db_content_excerpt = td_util::get_option($current_module_class . '_content_excerpt');
- if ($db_content_excerpt != '') {
- //cut from the database settings
- $buffy .= td_util::excerpt($this->post->post_content, $db_content_excerpt);
- } else {
- //cut at the default size
- $module_api = td_api_module::get_by_id($current_module_class);
- $buffy .= td_util::excerpt($this->post->post_content, $module_api['excerpt_content']);
- }
- } else {
- /**
- * no $cut_at provided and no setting in td_config -> return the full $this->post->post_content
- * @see td_global::$modules_list
- */
- $buffy .= $this->post->post_content;
- }
- }
- return $buffy;
- } else {
- /* ----------------------------------------------------------------------------
- Prepare the content
- */
- $content = get_the_content(__td('Continue', TD_THEME_NAME));
- $content = apply_filters('the_content', $content);
- $content = str_replace(']]>', ']]>', $content);
- /** ----------------------------------------------------------------------------
- * Smart list support. class_exists and new object WORK VIA AUTOLOAD
- * @see td_autoload_classes::loading_classes
- */
- //$td_smart_list = get_post_meta($this->post->ID, 'td_smart_list', true);
- $td_smart_list = get_post_meta($this->post->ID, 'td_post_theme_settings', true);
- if (!empty($td_smart_list['smart_list_template'])) {
- $td_smart_list_class = $td_smart_list['smart_list_template'];
- if (class_exists($td_smart_list_class)) {
- /**
- * @var $td_smart_list_obj td_smart_list
- */
- $td_smart_list_obj = new $td_smart_list_class(); // make the class from string * magic :)
- // prepare the settings for the smart list
- $smart_list_settings = array(
- 'post_content' => $content,
- 'counting_order_asc' => false,
- 'td_smart_list_h' => 'h3'
- );
- if (!empty($td_smart_list['td_smart_list_order'])) {
- $smart_list_settings['counting_order_asc'] = true;
- }
- if (!empty($td_smart_list['td_smart_list_h'])) {
- $smart_list_settings['td_smart_list_h'] = $td_smart_list['td_smart_list_h'];
- }
- return $td_smart_list_obj->render_from_post_content($smart_list_settings);
- } else {
- // there was an error?
- td_util::error(__FILE__, 'Missing smart list: ' . $td_smart_list_class . '. Did you disabled a tagDiv plugin?');
- }
- }
- /* ----------------------------------------------------------------------------
- end smart list - if we have a list, the function returns above
- */
- /* ----------------------------------------------------------------------------
- ad support on content
- */
- //read the current ad settings
- $tds_inline_ad_paragraph = td_util::get_option('tds_inline_ad_paragraph');
- $tds_inline_ad_align = td_util::get_option('tds_inline_ad_align');
- //add the inline ad
- if (td_util::is_ad_spot_enabled('content_inline') and is_single()) {
- if (empty($tds_inline_ad_paragraph)) {
- $tds_inline_ad_paragraph = 0;
- }
- $cnt = 0;
- $content_buffer = ''; // we replace the content with this buffer at the end
- $content_parts = preg_split('/(<p.*>)/U', $content, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
- foreach ($content_parts as $content_part_index => $content_part_value) {
- if (!empty($content_part_value)) {
- if ($tds_inline_ad_paragraph == ($content_part_index / 2)) {
- //it's time to show the ad
- switch ($tds_inline_ad_align) {
- case 'left':
- $content_buffer .= td_global_blocks::get_instance('td_block_ad_box')->render(array('spot_id' => 'content_inline', 'align' => 'left'));
- break;
- case 'right':
- $content_buffer .= td_global_blocks::get_instance('td_block_ad_box')->render(array('spot_id' => 'content_inline', 'align' => 'right'));
- break;
- default:
- $content_buffer .= td_global_blocks::get_instance('td_block_ad_box')->render(array('spot_id' => 'content_inline'));
- break;
- }
- }
- $content_buffer .= $content_part_value;
- $cnt++;
- }
- }
- $content = $content_buffer;
- }
- //add the top ad
- if (td_util::is_ad_spot_enabled('content_top') and is_single()) {
- $content = td_global_blocks::get_instance('td_block_ad_box')->render(array('spot_id' => 'content_top')) . $content;
- }
- //add bottom ad
- if (td_util::is_ad_spot_enabled('content_bottom') and is_single()) {
- $content = $content . td_global_blocks::get_instance('td_block_ad_box')->render(array('spot_id' => 'content_bottom'));
- }
- return $content;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment