$middle)
array_pop($positions);
$triggerpoint = $positions[floor(sizeof($positions)/2)];
/*End of Finding a appropriate position near the middle of the content to insert the ad*/
if ($middle > 2) {
$ad_style = get_option('wp_insert_in_post_ad_middle_'.$ad_ID.'_style');
if($ad_style == '') { $ad_style = 'margin: 5px; padding: 0px;'; }
if(!get_option('wp_insert_in_post_ad_middle_'.$ad_ID.'_exclude_home') && ($page_details == 'HOME')) {
switch($random) {
case 0:
$content = substr_replace($content, '
'.get_option('wp_insert_in_post_ad_middle_'.$ad_ID.'_content').'
'.$trigger, $triggerpoint, 2);
break;
case 1:
$content = substr_replace($content, ''.get_option('wp_insert_in_post_ad_middle_'.$ad_ID.'_content_1').'
'.$trigger, $triggerpoint, 2);
break;
case 2:
$content = substr_replace($content, ''.get_option('wp_insert_in_post_ad_middle_'.$ad_ID.'_content_2').'
'.$trigger, $triggerpoint, 2);
break;
}
}
else if(!get_option('wp_insert_in_post_ad_middle_'.$ad_ID.'_exclude_archives') && ($page_details == 'ARCHIVE')) {
switch($random) {
case 0:
$content = substr_replace($content, ''.get_option('wp_insert_in_post_ad_middle_'.$ad_ID.'_content').'
'.$trigger, $triggerpoint, 2);
break;
case 1:
$content = substr_replace($content, ''.get_option('wp_insert_in_post_ad_middle_'.$ad_ID.'_content_1').'
'.$trigger, $triggerpoint, 2);
break;
case 2:
$content = substr_replace($content, ''.get_option('wp_insert_in_post_ad_middle_'.$ad_ID.'_content_2').'
'.$trigger, $triggerpoint, 2);
break;
}
}
else {
if(is_singular()) {
$page_ids = explode(',', str_replace(" ", "", get_option('wp_insert_in_post_ad_middle_'.$ad_ID.'_exclude_ids')));
if(wp_insert_is_in_array($page_details, $page_ids) =='FALSE') {
switch($random) {
case 0:
$content = substr_replace($content, ''.get_option('wp_insert_in_post_ad_middle_'.$ad_ID.'_content').'
'.$trigger, $triggerpoint, 2);
break;
case 1:
$content = substr_replace($content, ''.get_option('wp_insert_in_post_ad_middle_'.$ad_ID.'_content_1').'
'.$trigger, $triggerpoint, 2);
break;
case 2:
$content = substr_replace($content, ''.get_option('wp_insert_in_post_ad_middle_'.$ad_ID.'_content_2').'
'.$trigger, $triggerpoint, 2);
break;
}
}
}
}
}
}
if(get_option('wp_insert_in_post_ad_top_'.$ad_ID.'_enable')) {
$ad_style = get_option('wp_insert_in_post_ad_top_'.$ad_ID.'_style');
if($ad_style == '') { $ad_style = 'margin: 5px; padding: 0px;'; }
if(!get_option('wp_insert_in_post_ad_top_'.$ad_ID.'_exclude_home') && ($page_details == 'HOME')) {
switch($random) {
case 0:
$output .= ''.get_option('wp_insert_in_post_ad_top_'.$ad_ID.'_content').'
';
break;
case 1:
$output .= ''.get_option('wp_insert_in_post_ad_top_'.$ad_ID.'_content_1').'
';
break;
case 2:
$output .= ''.get_option('wp_insert_in_post_ad_top_'.$ad_ID.'_content_2').'
';
break;
}
}
else if(!get_option('wp_insert_in_post_ad_top_'.$ad_ID.'_exclude_archives') && ($page_details == 'ARCHIVE')) {
switch($random) {
case 0:
$output .= ''.get_option('wp_insert_in_post_ad_top_'.$ad_ID.'_content').'
';
break;
case 1:
$output .= ''.get_option('wp_insert_in_post_ad_top_'.$ad_ID.'_content_1').'
';
break;
case 2:
$output .= ''.get_option('wp_insert_in_post_ad_top_'.$ad_ID.'_content_2').'
';
break;
}
}
else {
if(is_singular()) {
$page_ids = explode(',', str_replace(" ", "", get_option('wp_insert_in_post_ad_top_'.$ad_ID.'_exclude_ids')));
if(wp_insert_is_in_array($page_details, $page_ids) =='FALSE') {
switch($random) {
case 0:
$output .= ''.get_option('wp_insert_in_post_ad_top_'.$ad_ID.'_content').'
';
break;
case 1:
$output .= ''.get_option('wp_insert_in_post_ad_top_'.$ad_ID.'_content_1').'
';
break;
case 2:
$output .= ''.get_option('wp_insert_in_post_ad_top_'.$ad_ID.'_content_2').'
';
break;
}
}
}
}
}
if(get_option('wp_insert_in_post_ad_left_'.$ad_ID.'_enable')) {
$ad_style = get_option('wp_insert_in_post_ad_left_'.$ad_ID.'_style');
if($ad_style == '') { $ad_style = 'margin: 5px; padding: 0px;'; }
if(!get_option('wp_insert_in_post_ad_left_'.$ad_ID.'_exclude_home') && ($page_details == 'HOME')) {
switch($random) {
case 0:
$output .= ''.get_option('wp_insert_in_post_ad_left_'.$ad_ID.'_content').'
';
break;
case 1:
$output .= ''.get_option('wp_insert_in_post_ad_left_'.$ad_ID.'_content_1').'
';
break;
case 2:
$output .= ''.get_option('wp_insert_in_post_ad_left_'.$ad_ID.'_content_2').'
';
break;
}
}
else if(!get_option('wp_insert_in_post_ad_left_'.$ad_ID.'_exclude_archives') && ($page_details == 'ARCHIVE')) {
switch($random) {
case 0:
$output .= ''.get_option('wp_insert_in_post_ad_left_'.$ad_ID.'_content').'
';
break;
case 1:
$output .= ''.get_option('wp_insert_in_post_ad_left_'.$ad_ID.'_content_1').'
';
break;
case 2:
$output .= ''.get_option('wp_insert_in_post_ad_left_'.$ad_ID.'_content_2').'
';
break;
}
}
else {
if(is_singular()) {
$page_ids = explode(',', str_replace(" ", "", get_option('wp_insert_in_post_ad_left_'.$ad_ID.'_exclude_ids')));
if(wp_insert_is_in_array($page_details, $page_ids) =='FALSE') {
switch($random) {
case 0:
$output .= ''.get_option('wp_insert_in_post_ad_left_'.$ad_ID.'_content').'
';
break;
case 1:
$output .= ''.get_option('wp_insert_in_post_ad_left_'.$ad_ID.'_content_1').'
';
break;
case 2:
$output .= ''.get_option('wp_insert_in_post_ad_left_'.$ad_ID.'_content_2').'
';
break;
}
}
}
}
}
if(get_option('wp_insert_in_post_ad_right_'.$ad_ID.'_enable')) {
$ad_style = get_option('wp_insert_in_post_ad_right_'.$ad_ID.'_style');
if($ad_style == '') { $ad_style = 'margin: 5px; padding: 0px;'; }
if(!get_option('wp_insert_in_post_ad_right_'.$ad_ID.'_exclude_home') && ($page_details == 'HOME')) {
switch($random) {
case 0:
$output .= ''.get_option('wp_insert_in_post_ad_right_'.$ad_ID.'_content').'
';
break;
case 1:
$output .= ''.get_option('wp_insert_in_post_ad_right_'.$ad_ID.'_content_1').'
';
break;
case 2:
$output .= ''.get_option('wp_insert_in_post_ad_right_'.$ad_ID.'_content_2').'
';
break;
}
}
else if(!get_option('wp_insert_in_post_ad_right_'.$ad_ID.'_exclude_archives') && ($page_details == 'ARCHIVE')) {
switch($random) {
case 0:
$output .= ''.get_option('wp_insert_in_post_ad_right_'.$ad_ID.'_content').'
';
break;
case 1:
$output .= ''.get_option('wp_insert_in_post_ad_right_'.$ad_ID.'_content_1').'
';
break;
case 2:
$output .= ''.get_option('wp_insert_in_post_ad_right_'.$ad_ID.'_content_2').'
';
break;
}
}
else {
if(is_singular()) {
$page_ids = explode(',', str_replace(" ", "", get_option('wp_insert_in_post_ad_right_'.$ad_ID.'_exclude_ids')));
if(wp_insert_is_in_array($page_details, $page_ids) =='FALSE') {
switch($random) {
case 0:
$output .= ''.get_option('wp_insert_in_post_ad_right_'.$ad_ID.'_content').'
';
break;
case 1:
$output .= ''.get_option('wp_insert_in_post_ad_right_'.$ad_ID.'_content_1').'
';
break;
case 2:
$output .= ''.get_option('wp_insert_in_post_ad_right_'.$ad_ID.'_content_2').'
';
break;
}
}
}
}
}
if(get_option('wp_insert_in_post_ad_bottom_'.$ad_ID.'_enable')) {
$ad_style = get_option('wp_insert_in_post_ad_bottom_'.$ad_ID.'_style');
if($ad_style == '') { $ad_style = 'margin: 5px; padding: 0px;'; }
if(!get_option('wp_insert_in_post_ad_bottom_'.$ad_ID.'_exclude_home') && ($page_details == 'HOME')) {
switch($random) {
case 0:
$content .= ''.get_option('wp_insert_in_post_ad_bottom_'.$ad_ID.'_content').'
';
break;
case 1:
$content .= ''.get_option('wp_insert_in_post_ad_bottom_'.$ad_ID.'_content_1').'
';
break;
case 2:
$content .= ''.get_option('wp_insert_in_post_ad_bottom_'.$ad_ID.'_content_2').'
';
break;
}
}
else if(!get_option('wp_insert_in_post_ad_bottom_'.$ad_ID.'_exclude_archives') && ($page_details == 'ARCHIVE')) {
switch($random) {
case 0:
$content .= ''.get_option('wp_insert_in_post_ad_bottom_'.$ad_ID.'_content').'
';
break;
case 1:
$content .= ''.get_option('wp_insert_in_post_ad_bottom_'.$ad_ID.'_content_1').'
';
break;
case 2:
$content .= ''.get_option('wp_insert_in_post_ad_bottom_'.$ad_ID.'_content_2').'
';
break;
}
}
else {
if(is_singular()) {
$page_ids = explode(',', str_replace(" ", "", get_option('wp_insert_in_post_ad_bottom_'.$ad_ID.'_exclude_ids')));
if(wp_insert_is_in_array($page_details, $page_ids) =='FALSE') {
switch($random) {
case 0:
$content .= ''.get_option('wp_insert_in_post_ad_bottom_'.$ad_ID.'_content').'
';
break;
case 1:
$content .= ''.get_option('wp_insert_in_post_ad_bottom_'.$ad_ID.'_content_1').'
';
break;
case 2:
$content .= ''.get_option('wp_insert_in_post_ad_bottom_'.$ad_ID.'_content_2').'
';
break;
}
}
}
}
}
$content = $output.$content."";
return $content;
}
?>