ID;
//make sure the page is not trashed...
$the_page->post_status = 'publish';
$the_page_id = wp_update_post( $the_page );
}
delete_option( 'my_plugin_page_id' );
add_option( 'my_plugin_page_id', $the_page_id );
}
function dogmanage_remove() {
global $wpdb;
$the_page_title = get_option( "my_plugin_page_title" );
$the_page_name = get_option( "my_plugin_page_name" );
// the id of our page...
$the_page_id = get_option( 'my_plugin_page_id' );
if( $the_page_id ) {
wp_delete_post( $the_page_id ); // this will trash, not delete
}
delete_option("my_plugin_page_title");
delete_option("my_plugin_page_name");
delete_option("my_plugin_page_id");
}
function dogmanage(){
global $post;
if($post->post_title=='Koerte haldamine'){
global $current_user;
get_currentuserinfo();
/* adding dog into a database + form validating*/
$echo = '';
$dognameclass = 'dog-field';
$dogweightclass = 'dog-field';
$dogbreedclass = 'dog-field';
$dogageclass = 'dog-field';
if($_POST['add-dog']){
$dogname = $_POST['dog-name'];
$dogweight = $_POST['dog-weight'];
$dogbreed = $_POST['dog-breed'];
$dogage = $_POST['dog-age'];
$dogpregnant = $_POST['dog-pregnant'];
$validate=1;
if($dogpregnant=='on'){
$checked = 'checked';
$dogpregnant = 1;
}
if($dogname==''){$dognameclass = 'dog-field-error"'; $echo .= '
Nime väli tühi!
'; $validate=0;}
$dogweight = str_replace(',','.',$dogweight);
if($dogweight=='' || !is_numeric($dogweight)){$dogweightclass = 'dog-field-error'; $echo .= 'Kaalu väli on tühi või ei koosne numbritest!
'; $validate=0;}
if($dogbreed==''){$dogbreedclass = 'dog-field-error'; $echo .= 'Koeratõu väli tühi!
'; $validate=0;}
if($dogage=='' || !preg_match("/([0-2][0-9]|[0-3][0-1])\/([1][0-2]|[0][0-9])\/([0-9][0-9][0-9][0-9])/i", $dogage)){$dogageclass = 'dog-field-error'; $echo .= 'Koera sünnipäev valimata või vale formaat!
'; $validate=0;}
if($dogname!='' && $dogweight!='' && $dogbreed!='' && $dogage!='' && $validate==1){
$dogage = strtotime($dogage);
$querybreed = mysql_query('SELECT * FROM wp_dog_breed WHERE breed="'.$dogbreed.'" LIMIT 1');
if(mysql_num_rows($querybreed)!=0){
$row = mysql_fetch_array($querybreed);
$breedid = $row['id'];
} else {
mysql_query('INSERT INTO wp_dog_breed SET breed="'.$dogbreed.'"');
$querybreed = mysql_query('SELECT * FROM wp_dog_breed WHERE breed="'.$dogbreed.'" LIMIT 1');
$row = mysql_fetch_array($querybreed);
$breedid = $row['id'];
}
mysql_query('INSERT INTO wp_dog_base SET owners_id="'.$current_user->ID.'", dog_name="'.$dogname.'", dog_weight="'.$dogweight.'", dog_breed="'.$breedid.'", dog_age="'.$dogage.'", dog_pregnant="'.$dogpregnant.'", date_added="'.time().'"');
$echo .= 'Teie koer on lisatud meie andmebaasi!';
}
}
/* end of adding dog into a database + form validating*/
?>
nickname!=''){
?>
Lisa/Muuda koeri
Teie koerad
ID.'');
while($row = mysql_fetch_array($query)){
$birthdate = $row['dog_age'];
$agestamp = time()-$birthdate;
$age = ceil($agestamp/60/60/24/365);
if($age<2){
if($row['dog_pregnant']==1){
$puppy .= $row['dog_name'].', '.$row['breed'].' '.$age.'a (tiine)
';
} else {
$puppy .= $row['dog_name'].', '.$row['breed'].' '.$age.'a
';
}
} else {
if($row['dog_pregnant']==1){
$adult .= $row['dog_name'].', '.$row['breed'].' '.$age.'a (tiine)
';
} else {
$adult .= $row['dog_name'].', '.$row['breed'].' '.$age.'a)
';
}
}
}
?>
'.$puppy; } ?>
'.$adult; } ?>
Logige sisse!';
}
?>
post_content;
}
}
add_filter('the_content', 'dogmanage');
?>