/** * the content of a single post or single post type * @return mixed|string|void */ function get_content() { /* ---------------------------------------------------------------------------- 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', 'extract_first_image' => td_api_smart_list::get_key($td_smart_list_class, 'extract_first_image')); 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); $p_open_tag_count = 0; // count how many <p> tags we have added to the buffer foreach ($content_parts as $content_part_index => $content_part_value) { if (!empty($content_part_value)) { // 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> // and prevent cases like <p> ~ad~ content</p> if (preg_match('/(<p.*>)/U', $content_part_value) === 1) { if ($tds_inline_ad_paragraph == $p_open_tag_count) { 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; } } $p_open_tag_count++; } $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; }