ID)); $interval = date_diff($today, $published); $age = $interval->format('%a'); if ( $age >= ot_get_option('duration-ads-top') ) { if (ot_get_option('ad-after-post-title')) { $content = '
' . ot_get_option('ad-after-post-title') . '
' . $content; } if (ot_get_option('ad-middle-post')) { $content = pingraphy_ad_middle_content($content, '
' . ot_get_option('ad-middle-post') . '
'); } if (ot_get_option('ad-below-post')) { $content = $content . '
' . ot_get_option('ad-below-post') . '
'; } } return $content; } add_filter('the_content', 'pingraphy_ad_managment'); endif; /** |------------------------------------------------------------------------------ | Render ads middle post content |------------------------------------------------------------------------------ | | @return string | */ function pingraphy_ad_middle_content( $content, $middle_ad ) { $content = explode("

", $content); $new_content = ''; $paragraphAfter = round(count($content)/2); //Enter number of paragraphs to display ad after. for ($i = 0; $i < count($content); $i++) { if ($i == $paragraphAfter) { $new_content .= $middle_ad; } $new_content.= $content[$i] . "

"; } return $new_content; }