/** * Updates a patchchat by adding a comment * * @author caseypatrickdriscoll * * @edited 2015-08-04 15:02:36 - Adds updating of transient array * @edited 2015-08-29 16:43:15 - Refactors for more specialized performance and reusability * * @param Array $comment */ private static function add_comment($comment) { $current_user = wp_get_current_user(); if ($current_user->ID == 0) { return array('error' => 'User is not logged in'); } $comment['user_id'] = $current_user->ID; $comment['comment_date'] = current_time('mysql'); $comment['comment_author_IP'] = $_SERVER['REMOTE_ADDR']; $comment['comment_agent'] = $_SERVER['HTTP_USER_AGENT']; $comment_id = wp_insert_comment($comment); $comment['comment_ID'] = $comment_id; $transient = PatchChat_Transient::add_comment($comment); return true; }