ID,$blokedPostsArray,true)) $post_permission=0; } //ADS EXCLUDE FROM USERS POSTS if(get_option('adm_gs_a_exclue')){ $blocked_author = intval(get_option('adm_gs_a_exclue')); if ($post->post_author == $blocked_author) $author_permission=0; } //ADS HIDE FROM PAGES if(!get_option('abm_appearance_check_page')) { if(is_page()) return $content; } //ADS HIDE FROM POSTS if(!get_option('abm_appearance_check_post')){ if(is_single()) return $content; } //ADS HIDE FROM CATEGORIES if(get_option('abm_appearance_check_cat')){ if(is_category()) return $content; } //ADS HIDE FROM ARCHIVES if(get_option('abm_appearance_check_archive')){ if(is_archive()) return $content; } //ADS HIDE FROM HOMEPAGE if(get_option('abm_appearance_check_home')){ if(is_front_page() or is_home()) return $content; } if($post_permission == 1): if($author_permission == 1): /*Add Ad top of the post*/ if(get_option('adm_gs_top')): $selectedAd = "adm_gs_".get_option('adm_gs_top_ad'); $selectedAdCode = get_option($selectedAd); $abmAd = ""; $abmAd = $abmAd."
$selectedAdCode
"; $abmAd = $abmAd."
"; $content = $abmAd . $content; endif; /*Add Ad Middle of the post*/ if(get_option('adm_gs_mop')): $selectedAd = "adm_gs_".get_option('adm_gs_mop_ad'); $selectedAdCode = get_option($selectedAd); $abmAd = ""; $abmAd = $abmAd."
$selectedAdCode
"; $abmAd = $abmAd."
"; $after_character = count($content)/2; $tagscount = substr_count($content, '

'); $tagsMidway = intval($tagscount/2); $before_content = substr($content, 0, $after_character); $after_content = substr($content, $after_character); $after_content = explode('

', $after_content); array_splice($after_content, $tagsMidway, 0, $abmAd); $after_content = implode('

', $after_content); $content = $before_content . $after_content; endif; /*Add Ad End of the post*/ if(get_option('adm_gs_eop')): $selectedAd = "adm_gs_".get_option('adm_gs_eop_ad'); $selectedAdCode = get_option($selectedAd); $abmAd = ""; $abmAd = $abmAd."
$selectedAdCode
"; $abmAd = $abmAd."
"; $content = $content.$abmAd; endif; /*Add Ad After First Paragraph of the post*/ if(get_option('adm_gs_afp')): $selectedAd = "adm_gs_".get_option('adm_gs_afp_ad'); $selectedAdCode = get_option($selectedAd); $abmAd = ""; $abmAd = $abmAd."
$selectedAdCode
"; $abmAd = $abmAd."
"; $after_character = count($content)/2; $before_content = substr($content, 0, $after_character); $after_content = substr($content, $after_character); $after_content = explode('

', $after_content); array_splice($after_content, 1, 0, $abmAd); $after_content = implode('

', $after_content); $content = $before_content . $after_content; endif; /*Add Ad After First Image of the post*/ if(get_option('adm_gs_afi')): $selectedAd = "adm_gs_".get_option('adm_gs_afi_ad'); $selectedAdCode = get_option($selectedAd); $abmAd = ""; $abmAd = $abmAd."
$selectedAdCode
"; $abmAd = $abmAd."
"; if(preg_match('/(]+><\/a>)/i', $content, $a_tagmatch)){ //CONDITION TO CHECK IS A TAG AVAIL BEFORE IMG TAG $img = $a_tagmatch[0]; $newContents = explode("$img", $content); array_splice($newContents, 1, 0, $img.$abmAd); }elseif(preg_match('/(]+>)/i', $content, $img_tagmatch)){ //CONDITION TO CHECK IS A TAG NOT AVAIL BEFORE IMG TAG $img = $a_tagmatch[0]; $newContents = explode("$img", $content); array_splice($newContents, 1, 0, $img.$abmAd); }else{ //NO IMG TAG FOUND $newcontents = array($content); } $newContents = implode("", $newContents); $content = $newContents; endif; /*Add Ad Before First Image of the post*/ if(get_option('adm_gs_bfi')): $selectedAd = "adm_gs_".get_option('adm_gs_bfi_ad'); $selectedAdCode = get_option($selectedAd); $abmAd = ""; $abmAd = $abmAd."
$selectedAdCode
"; $abmAd = $abmAd."
"; if(preg_match('/(]+><\/a>)/i', $content, $a_tagmatch)){ //CONDITION TO CHECK IS A TAG AVAIL BEFORE IMG TAG $img = $a_tagmatch[0]; $newContents = explode("$img", $content); array_splice($newContents, 1, 0, $abmAd.$img); }elseif(preg_match('/(]+>)/i', $content, $img_tagmatch)){ //CONDITION TO CHECK IS A TAG NOT AVAIL BEFORE IMG TAG $img = $a_tagmatch[0]; $newContents = explode("$img", $content); array_splice($newContents, 1, 0, $abmAd.$img); }else{ //NO IMG TAG FOUND $newcontents = array($content); } $newContents = implode("", $newContents); $content = $newContents; endif; /*Add Ad Before Last Paragraph of the post*/ if(get_option('adm_gs_blp')): $selectedAd = "adm_gs_".get_option('adm_gs_blp_ad'); $selectedAdCode = get_option($selectedAd); $abmAd = ""; $abmAd = $abmAd."
$selectedAdCode
"; $abmAd = $abmAd."
"; $tagscount = substr_count($content, '

'); $insert_after = $tagscount - 1; $paragraphs = explode( '

', $content); // if array elements are less than $insert_after set the insert point at the end $len = count( $paragraphs ); if ( $len < $insert_after ) $insert_after = $len; // insert $abmAd into the array at the specified point array_splice( $paragraphs, $insert_after, 0, $abmAd ); // loop through array and build string for output foreach( $paragraphs as $paragraph ) { $newContents .= $paragraph; } $content = $newContents; endif; endif; endif; return $content; } add_filter('the_content', 'abm_add_to_content'); ?>