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 calculator_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 kalkulaator($content){ global $post; if($post->post_title=='Kalkulaator'){ global $current_user; get_currentuserinfo(); /* add food into storage */ if($_POST['add-kilo']){ $queryaddstorage = mysql_query('SELECT * FROM wp_food_storage WHERE owner_id="'.$current_user->ID.'" LIMIT 1'); $row = mysql_fetch_array($queryaddstorage); $totalstorage = $row['quantity']; if(mysql_num_rows($queryaddstorage)==0){ mysql_query('INSERT INTO wp_food_storage SET owner_id="'.$current_user->ID.'", quantity="1", date_added="'.time().'"'); } else { $totalstorage=$totalstorage+1; mysql_query('UPDATE wp_food_storage SET quantity='.$totalstorage.' WHERE owner_id="'.$current_user->ID.'"'); } } /* end of adding food into storage */ /* subtract food from storage */ if($_POST['subtract-kilo']){ $queryaddstorage = mysql_query('SELECT * FROM wp_food_storage WHERE owner_id="'.$current_user->ID.'" LIMIT 1'); $row = mysql_fetch_array($queryaddstorage); $totalstorage = $row['quantity']; $totalstorage=$totalstorage-1; mysql_query('UPDATE wp_food_storage SET quantity='.$totalstorage.' WHERE owner_id="'.$current_user->ID.'"'); } /* end of subtracting food from storage */ /* add custom food storage */ if($_POST['save-custom-storage']){ $queryaddstorage = mysql_query('SELECT * FROM wp_food_storage WHERE owner_id="'.$current_user->ID.'" LIMIT 1'); if(mysql_num_rows($queryaddstorage)==0){ mysql_query('INSERT INTO wp_food_storage SET owner_id="'.$current_user->ID.'", quantity="'.$_POST['custom-storage'].'", date_added="'.time().'"'); } else { mysql_query('UPDATE wp_food_storage SET quantity='.$_POST['custom-storage'].' WHERE owner_id="'.$current_user->ID.'"'); } } /* end of adding custom food storage */ ?>