public function save() { if (isset($_POST['delete_' . $this->name])) { $last_data = get_post_meta($this->post_id, $this->name, true); if ($last_data == "") { $last_data = false; } if ($last_data !== false) { custom_fields::remove_image($this->field['directory'], $last_data); update_post_meta($this->post_id, $this->name, ""); } } if (isset($_FILES[$this->name])) { $file = $_FILES[$this->name]; $data = custom_fields::upload_file($file, $this->field['directory']); if (strlen($data) > 0) { update_post_meta($this->post_id, $this->name, $data); } unset($_FILES[$this->name]); } }