get_row( $wpdb->prepare( "SELECT * FROM {$wpdb->prefix}wppm_task_comment WHERE id = %d AND task_id = %d", $comment_id,$task_id)); if(!(((!empty($task_comment)) && ($task_comment->created_by == $current_user->ID)) || ($current_user->has_cap('manage_options')) || ($wppmfunction->has_comment_permission('edit_task_comment',$task_id,$comment_id)))){ exit; } $attachment = absint( $attachment ); $result = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$wpdb->prefix}wppm_attachments WHERE id = %d", $attachment )); $file_path = isset( $result->file_path ) ? $result->file_path : ''; $attach_result = $wpdb->get_results( $wpdb->prepare( "SELECT file_path FROM {$wpdb->prefix}wppm_attachments WHERE file_path = %s", $file_path)); $result_count = count($attach_result); if(file_exists($result->file_path) && $result_count < 2) { wp_delete_file($result->file_path); } $success = $wpdb->delete( $wpdb->prefix . 'wppm_attachments', array( 'id' => "$attachment" ) ); if( !$success ) return false; $comment_id = isset( $comment_id ) ? absint( $comment_id ) : 0; $task_attachment = $wpdb->get_var( $wpdb->prepare( "SELECT attachment_ids FROM {$wpdb->prefix}wppm_task_comment WHERE id = %d", $comment_id)); $task_attachment = explode(",",$task_attachment); if(!empty($task_attachment)){ foreach($task_attachment as $key=>$val){ if($val == $attachment){ unset($task_attachment[$key]); } } } $tattachment = implode(',',$task_attachment); $values=array( 'attachment_ids'=>esc_sql($tattachment) ); $wpdb->update($wpdb->prefix.'wppm_task_comment', $values, array('id'=>"$comment_id")); $attachment = apply_filters('wppm_after_delete_comment_attachment',$attachment,$comment_id,$task_id);