$log->set_object('user', get_current_user_id()); $log->set('comment_id', $this->comment->get_uid()); $log->save(); $this->comment->errors['file'] = ''; if ($this->options['comment_upload']) { $wp_upload_dir = wp_upload_dir(); for ($i = 1; $i <= 3; $i++) { // up to 3 uploads per comment if (!empty($_FILES["tfk_file_{$i}"]['name'])) { $file = new tfk_item_file(); if ($file->upload("tfk_file_{$i}")) { $file->set('item_id', $this->pid); $file->set('user_id', get_current_user_id()); $file->set('file_tags', 'comment'); $file->save(); $this->comment->set('body', $this->comment->get('body') . '<p>' . __('Uploaded file: ', 'taskfreak') . '<a href="' . $wp_upload_dir['url'] . '/' . $file->get('file_name') . '" rel="external">' . $file->get('file_title') . '</a>' . '</p>'); $this->comment->update(); } else { $this->comment->errors['file'] .= '<p class="tfk_err">' . $file->error . '</p>'; } } // else no file, do nothing } } if (!$this->comment->errors['file']) { if (headers_sent()) { $this->data->load(); $this->comment->errors['global_errors'] = '<p class="tfk_ok">' . '<a id="tfk_back_list" href="' . esc_url(remove_query_arg('noheader')) . '#tfk_comment_' . $this->comment->get_uid() . '">' . __('See comment', 'taskfreak') . '</a>' . __('Comment saved.', 'taskfreak') . '</p>'; } else { wp_redirect(remove_query_arg('noheader', add_query_arg('view', $this->pid)) . '#tfk_comment_' . $this->comment->get_uid()); exit;