public function submitComment()
    {
        $answerId = (isset($_POST['answerid']) && is_numeric($_POST['answerid'])) ? $_POST['answerid'] : null;
        $postId = (isset($_POST['postid']) && is_numeric($_POST['postid'])) ? $_POST['postid'] : null;
        $comment = (isset($_POST['comment']) && strlen($_POST['comment']) > 0) ? $_POST['comment'] : null;
        $commentType = (isset($_POST['commenttype']) && strlen($_POST['commenttype']) > 0) ? $_POST['commenttype'] : null;
        $email = (isset($_POST['email']) && strlen($_POST['email']) > 0) ? $_POST['email'] : null;
        $topicId = (isset($_POST['topicid']) && is_numeric($_POST['topicid'])) ? (int)$_POST['topicid'] : null;

        $theme = wp_get_theme();
        if (!is_user_logged_in() && ($theme->name == 'Municipio' || $theme->parent_theme == 'Municipio')) {
            $response = (isset($_POST['captcha']) && strlen($_POST['captcha']) > 0) ? $_POST['captcha'] : null;
            $reCaptcha = \Municipio\Helper\ReCaptcha::controlReCaptcha($response);

            if (!$reCaptcha) {
                echo 'false';
                wp_die();
            }
        }

        if ($answerId && $postId) {
            update_post_meta($answerId, 'customer_feedback_comment', $comment);
            update_post_meta($answerId, 'customer_feedback_comment_type', $commentType);
            update_post_meta($answerId, 'customer_feedback_email', $email);
            if ($topicId) {
                wp_set_post_terms($answerId, array($topicId), 'feedback_topic');
            }

            wp_update_post(array(
                'ID' => $answerId,
                'post_status' => 'pending'
            ));

            \CustomerFeedback\Forwarding::maybeForward($answerId, $postId, $comment, $email, $topicId);

            echo 'true';
        } else {
            echo 'false';
        }

        wp_die();
    }
public function submitComment()
    {
        $answerId = (isset($_POST['answerid']) && is_numeric($_POST['answerid'])) ? $_POST['answerid'] : null;
        $postId = (isset($_POST['postid']) && is_numeric($_POST['postid'])) ? $_POST['postid'] : null;
        $comment = (isset($_POST['comment']) && strlen($_POST['comment']) > 0) ? $_POST['comment'] : null;
        $commentType = (isset($_POST['commenttype']) && strlen($_POST['commenttype']) > 0) ? $_POST['commenttype'] : null;
        $email = (isset($_POST['email']) && strlen($_POST['email']) > 0) ? $_POST['email'] : null;
        $topicId = (isset($_POST['topicid']) && is_numeric($_POST['topicid'])) ? (int)$_POST['topicid'] : null;

        $theme = wp_get_theme();
        if (!is_user_logged_in() && ($theme->name == 'Municipio' || $theme->parent_theme == 'Municipio')) {
            $response = (isset($_POST['captcha']) && strlen($_POST['captcha']) > 0) ? $_POST['captcha'] : null;
            $reCaptcha = \Municipio\Helper\ReCaptcha::controlReCaptcha($response);

            if (!$reCaptcha) {
                echo 'false';
                wp_die();
            }
        }

        if ($answerId && $postId) {
            update_post_meta($answerId, 'customer_feedback_comment', $comment);
            update_post_meta($answerId, 'customer_feedback_comment_type', $commentType);
            update_post_meta($answerId, 'customer_feedback_email', $email);
            if ($topicId) {
                wp_set_post_terms($answerId, array($topicId), 'feedback_topic');
            }

            wp_update_post(array(
                'ID' => $answerId,
                'post_status' => 'pending'
            ));

            \CustomerFeedback\Forwarding::maybeForward($answerId, $postId, $comment, $email, $topicId);

            echo 'true';
        } else {
            echo 'false';
        }

        wp_die();
    }
public function submitComment ( ) { $ answerId = ( isset ( $ _POST [ 'answerid' ] ) && is_numeric ( $ _POST [ 'answerid' ] ) ) ? $ _POST [ 'answerid' ] : null ; $ postId = ( isset ( $ _POST [ 'postid' ] ) && is_numeric ( $ _POST [ 'postid' ] ) ) ? $ _POST [ 'postid' ] : null ; $ comment = ( isset ( $ _POST [ 'comment' ] ) && strlen ( $ _POST [ 'comment' ] ) > 0 ) ? $ _POST [ 'comment' ] : null ; $ commentType = ( isset ( $ _POST [ 'commenttype' ] ) && strlen ( $ _POST [ 'commenttype' ] ) > 0 ) ? $ _POST [ 'commenttype' ] : null ; $ email = ( isset ( $ _POST [ 'email' ] ) && strlen ( $ _POST [ 'email' ] ) > 0 ) ? $ _POST [ 'email' ] : null ; $ topicId = ( isset ( $ _POST [ 'topicid' ] ) && is_numeric ( $ _POST [ 'topicid' ] ) ) ? ( int ) $ _POST [ 'topicid' ] : null ; $ theme = wp_get_theme ( ) ; if ( ! is_user_logged_in ( ) && ( $ theme -> name == 'Municipio' || $ theme -> parent_theme == 'Municipio' ) ) { $ response = ( isset ( $ _POST [ 'captcha' ] ) && strlen ( $ _POST [ 'captcha' ] ) > 0 ) ? $ _POST [ 'captcha' ] : null ; $ reCaptcha = \ Municipio \ Helper \ ReCaptcha :: controlReCaptcha ( $ response ) ; if ( ! $ reCaptcha ) { echo 'false' ; wp_die ( ) ; } } if ( $ answerId && $ postId ) { update_post_meta ( $ answerId , 'customer_feedback_comment' , $ comment ) ; update_post_meta ( $ answerId , 'customer_feedback_comment_type' , $ commentType ) ; update_post_meta ( $ answerId , 'customer_feedback_email' , $ email ) ; if ( $ topicId ) { wp_set_post_terms ( $ answerId , array ( $ topicId ) , 'feedback_topic' ) ; } wp_update_post ( array ( 'ID' => $ answerId , 'post_status' => 'pending' ) ) ; \ CustomerFeedback \ Forwarding :: maybeForward ( $ answerId , $ postId , $ comment , $ email , $ topicId ) ; echo 'true' ; } else { echo 'false' ; } wp_die ( ) ; }
Save a comment response as metadata for the page commented on
@return string Always returns "true" as a string
Save a comment response as metadata for the page commented on