public function delete_post_type(){
    global $wpdb;

    //checking the nonce
    check_admin_referer('delete_post_type_mf_posttype');

    if( isset($_GET['post_type']) ){
      $post_type = $_GET['post_type'];

      if( $post_type ){

        $sql = $wpdb->prepare( "DELETE FROM ".MF_TABLE_POSTTYPES." WHERE type = '%s'",$post_type );
        $wpdb->query($sql);

        //delete all groups of post_type
        $sql_fields = $wpdb->prepare( "DELETE FROM ".MF_TABLE_CUSTOM_GROUPS." WHERE post_type = '%s'",$post_type );
        $wpdb->query($sql_fields);

        //delete field of post_type
        $sql_fields = $wpdb->prepare( "DELETE FROM ".MF_TABLE_CUSTOM_FIELDS." WHERE post_type = '%s'",$post_type );
        $wpdb->query($sql_fields);

        $this->mf_redirect(null,null,array('message' => 'success'));
      }
    }
  }