function cp_onload_page()
 {
     // Ensure, that the needed javascripts been loaded to allow drag/drop, expand/collapse and hide/show of boxes
     wp_enqueue_script('common');
     wp_enqueue_script('wp-lists');
     wp_enqueue_script('postbox');
     // Add several metaboxes now, all metaboxes registered during load page can be switched off/on at "Screen Options" automatically, nothing special to do therefore
     add_meta_box('cp-dashboard-metaboxes-sidebox-1', __('Calendar', 'collabpress'), array(&$this, 'cp_dashboard_onsidebox_1_content'), $this->pagehook, 'side', 'core');
     add_meta_box('cp-dashboard-metaboxes-sidebox-2', __('Projects', 'collabpress'), array(&$this, 'cp_dashboard_onsidebox_2_content'), $this->pagehook, 'side', 'core');
     add_meta_box('cp-dashboard-metaboxes-sidebox-3', __('Users', 'collabpress'), array(&$this, 'cp_dashboard_onsidebox_3_content'), $this->pagehook, 'side', 'core');
     // All activity
     if (isset($_GET['view']) && $_GET['view'] == 'allactivity') {
         add_meta_box('cp-dashboard-metaboxes-contentbox-3', __('Activity', 'collabpress'), array(&$this, 'cp_dashboard_oncontentbox_3_content'), $this->pagehook, 'normal', 'core');
         // All my tasks
     } else {
         if (isset($_GET['view']) && $_GET['view'] == 'allmytasks') {
             add_meta_box('cp-dashboard-metaboxes-contentbox-4', __('My Tasks', 'collabpress'), array(&$this, 'cp_dashboard_oncontentbox_4_content'), $this->pagehook, 'normal', 'core');
             // All tasks
         } else {
             if (isset($_GET['view']) && $_GET['view'] == 'alltasks') {
                 add_meta_box('cp-dashboard-metaboxes-contentbox-5', __('Tasks', 'collabpress'), array(&$this, 'cp_dashboard_oncontentbox_5_content'), $this->pagehook, 'normal', 'core');
                 // User page
             } else {
                 if (isset($_GET['view']) && $_GET['view'] == 'userpage') {
                     $user_info = get_userdata($_GET['user']);
                     add_meta_box('cp-dashboard-metaboxes-contentbox-6', 'Tasks for ' . $user_info->user_nicename, array(&$this, 'cp_dashboard_oncontentbox_6_content'), $this->pagehook, 'normal', 'core');
                     // Task page
                 } else {
                     if (isset($_GET['view']) && $_GET['view'] == 'task') {
                         $task_data = get_taskdata(intval($_GET['task_id']));
                         add_meta_box('cp-dashboard-metaboxes-contentbox-7', 'Task: ' . stripslashes($task_data->title), array(&$this, 'cp_dashboard_oncontentbox_7_content'), $this->pagehook, 'normal', 'core');
                         // Dashboard
                     } else {
                         add_meta_box('cp-dashboard-metaboxes-contentbox-1', __('Recent Activity', 'collabpress'), array(&$this, 'cp_dashboard_oncontentbox_1_content'), $this->pagehook, 'normal', 'core');
                         add_meta_box('cp-dashboard-metaboxes-contentbox-2', __('My Tasks', 'collabpress'), array(&$this, 'cp_dashboard_oncontentbox_2_content'), $this->pagehook, 'normal', 'core');
                         add_meta_box('cp-dashboard-metaboxes-contentbox-additional-2', __('About', 'collabpress'), array(&$this, 'cp_dashboard_oncontentbox_additional_2_content'), $this->pagehook, 'additional', 'core');
                     }
                 }
             }
         }
     }
 }
	<div class="error">
		<p><strong><?php 
    _e('Project Deleted', 'collabpress');
    ?>
</strong></p>
	</div>
	
<?php 
}
// Add a comment
if (isset($_POST['cp_add_comment_button'])) {
    check_admin_referer('cp-add-task-comment');
    global $wpdb, $current_user, $cp_email_footer;
    // 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'])) {
    function cp_projects_oncontentbox_5_content($data)
    {
        if (check_cp_task_exists(esc_html($_GET['task']))) {
            $edit_task = get_taskdata(esc_html($_GET['task']));
            ?>
		
			<form method="post" action="" enctype="multipart/form-data">
			<?php 
            wp_nonce_field('cp-edit-task');
            ?>

			<table class="form-table">
			<tr class="form-field form-required">
			<th scope="row"><label for="cp_title"><?php 
            _e('Title: ', 'collabpress');
            ?>
 <span class="description"><?php 
            _e('(required)');
            ?>
</span></label></th>
			<td><input name="cp_title" type="text" id="cp_title" value="<?php 
            echo stripslashes($edit_task->title);
            ?>
" aria-required="true" /></td>
			</tr>

			<tr class="form-field">
			<th scope="row"><label for="cp_details"><?php 
            _e('Details: ', 'collabpress');
            ?>
</label></th>
			<td><textarea name="cp_details" id="cp_details" rows="10" cols="20" /><?php 
            echo stripslashes($edit_task->details);
            ?>
</textarea></td>
			</tr>

			<tr class="form-field">
			<th scope="row"><label for="cp_users"><?php 
            _e('Assign to: ', 'collabpress');
            ?>
</label></th>
			<td><?php 
            wp_dropdown_users('selected=' . $edit_task->users);
            ?>
<td>
			</tr>
		
			<?php 
            $edit_task_due_date = explode("-", $edit_task->due_date);
            ?>

			<tr class="form-field">
			<th scope="row"><label for="cp_tasks_due"><?php 
            _e('Due: ', 'collabpress');
            ?>
</label></th>
			<td>
			<?php 
            $months = array(1 => 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December');
            $days = range(1, 31);
            $years = range(date('Y'), 2025);
            // Month
            echo __('Month', 'collabpress') . ": <select name='cp_tasks_due_month'>";
            $cp_month_count = 1;
            foreach ($months as $value) {
                if ($cp_month_count == $edit_task_due_date[0]) {
                    $month_selected = "SELECTED";
                } else {
                    $month_selected = '';
                }
                echo '<option ' . $month_selected . ' value="' . $cp_month_count . '">' . $value . '</option>\\n';
                $cp_month_count++;
            }
            echo '</select>';
            // Day
            echo __('Day', 'collabpress') . ": <select name='cp_tasks_due_day'>";
            foreach ($days as $value) {
                if ($value == $edit_task_due_date[1]) {
                    $day_selected = "SELECTED";
                } else {
                    $day_selected = '';
                }
                echo '<option ' . $day_selected . ' value="' . $value . '">' . $value . '</option>\\n';
            }
            echo '</select>';
            // Year
            echo __('Year', 'collabpress') . ": <select name='cp_tasks_due_year'>";
            foreach ($years as $value) {
                if ($value == $edit_task_due_date[2]) {
                    $year_selected = "SELECTED";
                } else {
                    $year_selected = '';
                }
                echo '<option ' . $year_selected . ' value="' . $value . '">' . $value . '</option>\\n';
            }
            echo '</select>';
            ?>
			</td>
			</tr>

			</table>

			<input type="hidden" name="cp_edit_task_id" value="<?php 
            echo esc_html($_GET['task']);
            ?>
">
			<input type="hidden" name="cp_add_tasks_project" value="<?php 
            echo $edit_task->proj_id;
            ?>
">
			<input type="hidden" name="page_options" value="user, cp_title, cp_details, cp_users, cp_tasks_due_month, cp_tasks_due_day, cp_tasks_due_year, cp_add_tasks_project" />

			<p>
			<input type="submit" class="button-primary" name="cp_edit_task_button" value="<?php 
            _e('Edit Task', 'collabpress');
            ?>
" />
			</p>

			</form>
		<?php 
        } else {
            echo "<p>" . __("Task doesn't exist...", "collabpress") . "</p>";
        }
    }
function list_cp_task($task_id = NULL)
{
    global $wpdb, $current_user;
    $my_task_count = '';
    $task_id = intval($task_id);
    $task_data = get_taskdata($task_id);
    if ($task_data) {
        $user_info = get_userdata($task_data->users);
        if ($task_data->status != 1) {
            echo '<div style="height:auto">';
            echo '<div id="cp-gravatar" style="height:62px;width:62px;background:#F0F0F0;">';
            // Default gravatar
            $def_gravatar = "http://www.gravatar.com/avatar/c11f04eee71dfd0f49132786c34ea4ff?s=50&d=&r=G&forcedefault=1";
            // Get gravatar
            echo get_avatar($user_info->user_email, $size = '50', $default = $def_gravatar);
            echo '</div>';
            if ($task_data->users == $current_user->ID) {
                echo '<div style="background:#FFFFCC" id="cp-task-summary">';
            } else {
                echo '<div id="cp-task-summary">';
            }
            echo '<div style="margin-left:75px">';
            if ($task_data->status == 1) {
                echo ' <span style="text-decoration:line-through">';
            }
            echo "<strong>" . stripslashes($task_data->title) . "</strong>";
            $today = date("n-d-Y", mktime(date("n"), date("d"), date("Y")));
            $today_totime = strtotime($today);
            $duedate_totime = strtotime($task_data->due_date);
            if ($duedate_totime > $today_totime) {
                $date_color = "#DB4D4D";
            } else {
                $date_color = "#33FF99";
            }
            echo " <code style='background:" . $date_color . "'>" . __('Due', 'collabpress') . ": " . $task_data->due_date . "</code>";
            if ($task_data->status == 1) {
                echo '</span>';
            }
            //$link = 'admin.php?page='.$page_name.'&delete-task=' . $task_data->id . '&task-title=' . $task_data->title;
            //$link = ( function_exists('wp_nonce_url') ) ? wp_nonce_url($link, 'cp-action-delete_task') : $link;
            echo ' <a href="admin.php?page=cp-projects-page&view=edit-task&task=' . $task_data->id . '">edit</a>';
            //echo ' <a style="color:#D54E21" href="'.$link.'">delete</a></p>';
            // If there is a description
            if ($task_data->details) {
                echo '<p><strong>Description:</strong> ' . stripslashes(nl2br($task_data->details)) . '</p>';
            }
            require CP_PLUGIN_DIR . '/cp-core/cp-core-comments.php';
            $my_task_count++;
            echo '</div>';
            echo '</div>';
            echo '</div>';
        }
    } else {
        echo "<p>No tasks......</p>";
    }
}