has_project_permission('add_proj_comment',$proj_id)){ wp_send_json_error( 'Unauthorised request!', 403 ); } $cu_id = $current_user->ID; $project_data = $wppmfunction->get_project($proj_id); if (empty($project_data)) { wp_send_json_error( 'Project not found', 404 ); } $comment = !empty($_POST['comment_body']) ? wp_kses_post($_POST['comment_body']) : '' ; $allowed_tags = array( 'br' => array(), 'abbr' => array('title' => array(),), 'p' => array(), 'strong' => array(), 'a' => array('href' => array(), 'title' => array(), 'rel'=> array(), 'target'=> array()),'em' =>array(),'span' =>array(), 'blockquote'=>array('cite' => array(),),'div' => array('class' => array(),'title' => array(),'style' => array(),),'ul'=>array(),'li'=>array(),'ol'=>array(),'img' => array( 'alt'=> array(),'class' => array(),'height' => array(),'src'=> array(),'width'=> array(),)); $comment_body = wp_kses($comment,$allowed_tags); $attachments = !empty($_POST['wppm_proj_comment_attachment']) ? $wppmfunction->sanitize_array($_POST['wppm_proj_comment_attachment']) : []; $attachment_ids = implode(",",$attachments); if($comment_body=="" && $attachment_ids=="") exit; if(!empty($attachments)){ $project_auth_code = $wppmfunction->get_project_meta($proj_id,'project_auth_code',true); if(empty($project_auth_code)){ $auth_code = $wppmfunction->getRandomString(10); $wppmfunction->add_project_meta($proj_id,'project_auth_code',$auth_code); } } $vals = array('is_active' => 1); foreach($attachments as $attach){ $attach = esc_sql($attach); $wpdb->update($wpdb->prefix.'wppm_attachments', $vals, array('id'=>"$attach")); } $args=array( 'proj_id'=> $proj_id, 'body'=>$comment_body, 'attachment_ids'=>$attachment_ids, 'create_time'=>current_time('mysql', 1), 'created_by'=>$cu_id ); $args = apply_filters( 'wppm_submit_proj_comment_args', $args ); $comment_id = $wppmfunction->wppm_submit_proj_comment($args); $proj_log_values = array('proj_id'=>esc_sql($proj_id),'comment_id'=>esc_sql($comment_id),'comment_type'=>'comment'); $wpdb->insert($wpdb->prefix . 'wppm_project_comment_meta',$proj_log_values); do_action('wppm_after_submit_proj_comment', $proj_id,$comment_id);