Mozes da pokusas sa ovim. Ovo sam napisao bas za tu namenu da ubacuje neki div sa reklamom u text samog posta.
Ovo je glupa verzija koja ubacuje reklame posle n-te reci samo.
Kôd:
<?php
/*
Plugin Name: InThePost
Plugin URI: www.rednetcat.com
Description: Inserts code inside the post works with adsense delux plugin
Version: 0.2
Author: Ivandima
Author URI: www.dipdaun.com
*/
function itp_add_options(){
if(function_exists('add_options_page')){
add_options_page('Adsense InThePost', 'InThePost', 9, basename(__FILE__), 'itp_options_subpanel');
}
}
function itp_options_subpanel(){
update_option('inthepost',$_POST['adds']);
?>
<div class="wrap">
<h2>Adsense InThePost</h2>
<form name="form1" method="post">
<label>Adsense code for inserting in the post</label><textarea name="adds" cols="20" rows="20"><? echo htmlentities(get_option('inthepost'));?></textarea>
<input name="Submit" type="submit" value="Submit" />
</form>
</div>
<?
}
function inthepost($content){
$adds ="<div class=\"adds\">". stripslashes(get_option('inthepost'))."</div>";
//$broj_reci = str_word_count($content); $broj_reci=round($broj_reci/2);
$broj_reci=70;
$post = str_word_count($content, 2);
$content="";
$i=0;
foreach($post as $p){
if($i==$broj_reci) $content = $content . $adds ." ";
$content = $content. $p ." ";
$i++;
}
return $content;
}
add_action('admin_menu', 'itp_add_options');
add_filter('the_content', 'inthepost',10);
?>
Ovo je verzija koja ubacuje reklamu posle prvog </p> ( cini mi se ).
Kôd:
<?php
/*
Plugin Name: InThePost
Plugin URI: www.rednetcat.com
Description: Inserts code inside the post works with adsense delux plugin
Version: 0.1
Author: Ivandima
Author URI: www.rednetcat.com
*/
function itp_add_options(){
if(function_exists('add_options_page')){
add_options_page('Adsense InThePost', 'InThePost', 9, basename(__FILE__), 'itp_options_subpanel');
}
}
function itp_options_subpanel(){
update_option('inthepost',$_POST['adds']);
?>
<div class="wrap">
<h2>Adsense InThePost</h2>
<form name="form1" method="post">
<label>Adsense code for inserting in the post</label><textarea name="adds" cols="20" rows="20"><? echo htmlentities(get_option('inthepost'));?></textarea>
<input name="Submit" type="submit" value="Submit" />
</form>
</div>
<?
}
function inthepost($content){
$adds ="<div class=\"adds\">". stripslashes(get_option('inthepost'))."</div>";
$post = explode("<p>",$content); $content="";
$i=0; foreach($post as $p) $i++;
$dodato=0;
for($t=0;$t<$i;$t++){
if(($t>1)&&($dodato==0)){ $content .= $adds."<p>".$post[$i]; $dodato=1;}
else $content .= "<p>".$p;
}
return $content;
}
add_action('admin_menu', 'itp_add_options');
add_filter('the_content', 'inthepost',10);
?>