/** * Post a comment action */ public function postAction() { if ($this->isEnabledForStore()) { $challenge = $this->getRequest()->getPost('recaptcha_challenge_field'); $field = $this->getRequest()->getPost('recaptcha_response_field'); if ($post = $this->getPost()) { $data = new Varien_Object($this->getRequest()->getPost()); try { Mage::getSingleton('wordpress/session')->setPostCommentData($post, $data->getAuthor(), $data->getEmail(), $data->getUrl(), $data->getComment()); if (Mage::helper('wordpress/recaptcha')->isEnabled()) { if (!Mage::helper('wordpress/recaptcha')->isValidValue($challenge, $field, true)) { throw new Exception($this->getCaptchaErrorMessage()); } } $comment = $post->postComment($data->getAuthor(), $data->getEmail(), $data->getUrl(), $data->getComment(), $data->getExtra()); if (!$comment) { throw new Exception($this->getCommentErrorMessage()); } Mage::getSingleton('wordpress/session')->removePostCommentData($post); Mage::getSingleton('core/session')->addSuccess($this->__($this->getCommentSuccessMessage())); } catch (Exception $e) { Mage::getSingleton('core/session')->addError($this->__($e->getMessage())); } $this->_redirectUrl($post->getPermalink()); } else { $this->_forward('noRoute'); } } else { $this->_forward('noRoute'); } }