| @@ -6,9 +6,13 @@ | ||
| 6 | 6 | global $current_user, $wppmfunction,$wpdb; |
| 7 | 7 | $current_user_data = get_userdata($current_user->ID); |
| 8 | 8 | $task_id = intval(sanitize_text_field($task_id)); |
| 9 | 9 | $wppm_task_data = $wppmfunction->get_task($task_id); |
| 10 | -$wppm_task_comment = $wpdb->get_row("SELECT * FROM {$wpdb->prefix}wppm_task_comment where task_id='".$task_id."' ORDER BY id DESC LIMIT 1;"); | |
| 10 | +$task_creator = $wppm_task_data['created_by']; | |
| 11 | +$task_creator_data = get_userdata($task_creator); | |
| 12 | +$task_creator_name = $task_creator_data->display_name; | |
| 13 | +$orderby_sql = esc_sql(sanitize_sql_orderby( "id DESC" )); | |
| 14 | +$wppm_task_comment = $wpdb->get_row("SELECT * FROM {$wpdb->prefix}wppm_task_comment where task_id='".esc_sql($task_id)."' ORDER BY $orderby_sql LIMIT 1;"); | |
| 11 | 15 | $wppm_project_data = $wppmfunction->get_project($wppm_task_data['project']); |
| 12 | 16 | $auth_id = sanitize_text_field($wppm_task_data['task_auth_code']); |
| 13 | 17 | $attachments = array(); |
| 14 | 18 | if(!empty($wppm_task_comment)){ |
| @@ -22,8 +26,12 @@ | ||
| 22 | 26 | // Task ID |
| 23 | 27 | case '{task_id}': |
| 24 | 28 | $str = preg_replace('/{task_id}/', $task_id, $str); |
| 25 | 29 | break; |
| 30 | + // Task Creator Name | |
| 31 | + case '{task_creator_name}': | |
| 32 | + $str = preg_replace('/{task_creator_name}/', $task_creator_name, $str); | |
| 33 | + break; | |
| 26 | 34 | //Current User Name |
| 27 | 35 | case '{user_name}': |
| 28 | 36 | $str = preg_replace('/{user_name}/', sanitize_text_field($current_user_data->display_name), $str); |
| 29 | 37 | break; |
| @@ -86,9 +94,13 @@ | ||
| 86 | 94 | $str = preg_replace('/{project_status}/', $this->get_new_project_status_name((sanitize_text_field($wppm_project_data['status'])), $str)); |
| 87 | 95 | break; |
| 88 | 96 | // Project Category |
| 89 | 97 | case '{project_category}'; |
| 90 | - $str = preg_replace('/{project_category}/', $this->get_project_category_name((sanitize_text_field($wppm_project_data['cat_id'])), $str)); | |
| 98 | + if(!empty($wppm_project_data['cat_id'])){ | |
| 99 | + $str = preg_replace('/{project_category}/', $this->get_project_category_name(sanitize_text_field($wppm_project_data['cat_id'])), $str); | |
| 100 | + }else{ | |
| 101 | + $str = ""; | |
| 102 | + } | |
| 91 | 103 | break; |
| 92 | 104 | // Project Name |
| 93 | 105 | case '{project_name}': |
| 94 | 106 | $str = preg_replace('/{project_name}/', (sanitize_text_field($wppm_project_data['project_name'])), $str); |
| @@ -121,8 +133,9 @@ | ||
| 121 | 133 | if($flag == true){ |
| 122 | 134 | if(!empty($attachments)){ |
| 123 | 135 | foreach($attachments as $attach_id){ |
| 124 | 136 | $upload_dir = wp_upload_dir(); |
| 137 | + $attach_id = esc_sql($attach_id); | |
| 125 | 138 | $attachment = $wpdb->get_row("select * from {$wpdb->prefix}wppm_attachments where id='".$attach_id."'"); |
| 126 | 139 | if(!empty($attachment)){ |
| 127 | 140 | $updated_time = sanitize_text_field($attachment->date_created); |
| 128 | 141 | $time = strtotime(sanitize_text_field($updated_time)); |