Bir wordpress plugini fakat türkçe karekterler ü -ö gibi abuk subuk çıkıyor vede asıl önemlisi tarih hesaplama sonucunda -
tarihler ingilizce çıkıyor - tarihi nasıl türkçeleştirebilirim ? öüş karakterlerini nasıl çıkartabilirim ?
<?php
function ovpredct_add_page()
{
add_submenu_page('plugins.php', 'Ovulation Predictor Configuration', 'Ovulation Predictor Configuration', 8, __FILE__, 'ovpredct_options');
}
// ovpredct_options() displays the page content for the Ovpredct Options submenu
function ovpredct_options()
{
// Read in existing option value from database
$ovpredct_table = stripslashes( get_option( 'ovpredct_table' ) );
// See if the user has posted us some information
// If they did, this hidden field will be set to 'Y'
if( $_POST[ 'ocalc_update' ] == 'Y' )
{
// Read their posted value
$ovpredct_table = $_POST[ 'ovpredct_table' ];
// Save the posted value in the database
update_option( 'ovpredct_table', $ovpredct_table );
// Put an options updated message on the screen
?>
<div class="updated"><p><strong><?php _e('Options saved.', 'ovpredct_domain' ); ?></strong></p></div>
<?php
}
// Now display the options editing screen
echo '<div class="wrap">';
// header
echo "<h2>" . __( 'Ovulation Predictor Options', 'ovpredct_domain' ) . "</h2>";
// options form
?>
<form name="form1" method="post" action="<?php echo str_replace( '%7E', '~', $_SERVER['REQUEST_URI']); ?>">
<input type="hidden" name="ocalc_update" value="Y">
<p><?php _e("CSS class definition for the predictor <div>:", 'ovpredct_domain' ); ?>
<textarea name="ovpredct_table" rows='5' cols='70'><?php echo stripslashes ($ovpredct_table); ?></textarea>
</p><hr />
<p class="submit">
<input type="submit" name="Submit" value="<?php _e('Update Options', 'ovpredct_domain' ) ?>" />
</p>
</form>
</div>
<?php
}
function ovpredct_datechooser($name,$value="")
{
$months=array('',''Ocak','Subat','Mart','Nisan','Mayis','Haziran','Temmuz','Agustos','Eylul','Ekim','Kasim','Aralik');
if(empty($value)) $value=date("Y-m-d");
$parts=explode("-",$value);
$day=$parts[2]+0;
$month=$parts[1]+0;
$year=$parts[0];
$chooser="";
$chooser.="<select name=".$name."month>";
for($i=1;$i<=12;$i++)
{
if($i==$month) $selected='selected';
else $selected='';
$chooser.="<option $selected value=$i>$months[$i]</option>";
}
$chooser.="</select> / ";
$chooser.="<select name=".$name."day>";
for($i=1;$i<=31;$i++)
{
if($i==$day) $selected='selected';
else $selected='';
$chooser.="<option $selected>$i</option>";
}
$chooser.="</select> / ";
$chooser.="<select name=".$name."year>";
for($i=(date("Y")-1);$i<=2050;$i++)
{
if($i==$year) $selected='selected';
else $selected='';
$chooser.="<option $selected>$i</option>";
}
$chooser.="</select> ";
return $chooser;
}
// This just echoes the text
function ovpredct($content)
{
if(!strstr($content,"[ovulation-predictor]")) return $content;
//construct the calculator page
$ovcalc="<style type=\"text/css\">
.ovpredct_table
{
".get_option('ovpredct_table')."
}
</style>\n\n";
if(!empty($_POST['calculator_ok']))
{
//last cycle date
$date="$_POST[dateyear]-$_POST[datemonth]-$_POST[dateday]";
//convert to time
$lasttime=mktime(0,0,0,$_POST[datemonth],$_POST[dateday],$_POST[dateyear]);
//first fertile day
$firstdaytime=$lasttime + $_POST[days]*24*3600 - 16*24*3600;
$firstday=date("F d, Y",$firstdaytime);
//last fertile day
$lastdaytime=$lasttime + $_POST[days]*24*3600 - 12*24*3600;
$lastday=date("F d, Y",$lastdaytime);
//have to adjust due date?
$diff=$_POST[days] - 28;
//due date $date + 280 days
$duedatetime=$lasttime + 280*24*3600 + $diff*24*3600;
$duedate=date("F d, Y",$duedatetime);
//the result is here
$ovcalc.='<div class="ovpredct_table">
Here are the results based on the information you provided:<br /><br />
You next most fertile period is <strong>'.$firstday.' to '.$lastday.'</strong>.<br ><br />
If you conceive within this timeframe, your estimated due date will be <strong>'.$duedate.'</strong>
<p align="center"><input type="button" value="Calculate again!" onclick="javascript:history.back();"></p>
</div>';
}
else
{
$ovcalc.='<div class="ovpredct_table">
<form method="post">
Please select the first day of your last menstrual period:<br /><br />
'.ovpredct_datechooser("date",date("Y-m-d")).'<br><br>
Usual number of days in your cycle: <select name="days">';
for($i=20;$i<=45;$i++)
{
if($i==28) $selected='selected';
else $selected='';
$ovcalc.="<option $selected value='$i'>$i</option>";
}
$ovcalc.='</select>
<p align="center"><input type="submit" name="calculator_ok" value="Calculate"></p>
</form>
</div>';
}
$content=str_replace("[ovulation-predictor]",$ovcalc,$content);
return $content;
}
add_action('admin_menu','ovpredct_add_page');
add_filter('the_content', 'ovpredct');
?>