function delete_cp_task($task, $title = NULL)
{
    global $wpdb, $current_user;
    $cp_auth = $current_user->ID;
    $cp_date = date("Y-m-d H:m:s");
    $table_name = $wpdb->prefix . "cp_tasks";
    $wpdb->query("\r\n\tDELETE FROM {$table_name} WHERE id = {$task}");
    insert_cp_activity($cp_auth, $cp_date, 'deleted', $title, 'task', NULL);
}
function delete_cp_project($project_id)
{
    global $wpdb, $current_user;
    $cp_auth = $current_user->ID;
    $cp_date = date("Y-m-d H:m:s");
    $title = get_cp_project_title($project_id);
    // Delete project
    $table_name = $wpdb->prefix . "cp_projects";
    $wpdb->query("DELETE FROM {$table_name} WHERE id = {$project_id}");
    // Delete all tasks for project
    $table_name = $wpdb->prefix . "cp_tasks";
    $wpdb->query("DELETE FROM {$table_name} WHERE proj_id = {$project_id}");
    insert_cp_activity($cp_auth, $cp_date, 'deleted', $title, 'project', NULL);
}
 // Load task data
 $cp_task_id = intval($_POST['cp_task_id']);
 $task_data = get_taskdata($cp_task_id);
 // Load project data
 $cp_project_id = get_cp_task_project_id($cp_task_id);
 $project_data = get_projectdata($cp_project_id);
 $cp_task_comment = esc_html($_POST['cp_task_comment']);
 $cp_task_title = $task_data->title;
 $cp_project_title = $project_data->title;
 $cp_date = current_time('mysql');
 $cp_auth = $current_user->ID;
 $cp_users = esc_html($_POST['cp_author_id']);
 $table_name = $wpdb->prefix . "cp_tasksmeta";
 $results = $wpdb->insert($table_name, array('task_id' => $cp_task_id, 'auth' => $cp_auth, 'meta_key' => 'comment', 'meta_value' => $cp_task_comment, 'date' => $cp_date));
 // Add activity log record
 insert_cp_activity($cp_auth, $cp_date, 'added', $cp_task_title, 'comment', $cp_task_id);
 // Check if email notifications is enabled
 if (isset($_POST['notify'])) {
     // Send email to user assigned to task
     $user_info = get_userdata($cp_users);
     $cp_email = $user_info->user_email;
     $cp_subject = 'CollabPress: New comment on task';
     $cp_message = "Project: " . $cp_project_title . "\n";
     $cp_message .= "Task: " . $cp_task_title . "\n\n";
     $cp_message .= $current_user->display_name . " commented on a task:\n";
     $cp_message .= $cp_task_comment . "\n\n";
     $cp_message .= "To view this task visit:\n";
     $cp_message .= get_bloginfo('siteurl') . '/wp-admin/admin.php?page=cp-dashboard-page&view=task&task_id=' . $cp_task_id;
     $cp_message .= $cp_email_footer;
     // WP_Mail()
     wp_mail($cp_email, $cp_subject, $cp_message);