library/Comment/CommentsActions.php
public function getCommentForm()
    {
        $postId = $_POST['postId'] ?? null;
        $commentId = $_POST['commentId'] ?? null;

        if (!$commentId || !$postId || !$comment = get_comment($commentId)) {
            wp_send_json_error('Missing variables');
        }

        if (!$comment = get_comment($commentId)) {
            wp_send_json_error('Comment is missing');
        }

        $args = array(
            'id_form' => 'commentupdate',
            'class_submit' => 'btn btn-sm btn-primary',
            'title_reply' => '',
            'title_reply_before' => '',
            'title_reply_after' => '',
            'label_submit' => __('Update', 'municipio'),
            'logged_in_as' => '',
            'comment_field' => '<textarea id="update-comment" name="comment" cols="45" rows="8" aria-required="true">' . $comment->comment_content . '</textarea>',
            'comment_notes_after' => '<input type="hidden" name="commentId" value="' . $commentId . '">
            <input type="hidden" name="nonce" value="' . wp_create_nonce("update-comment_$commentId") . '">',
            'submit_button' => '<input name="%1$s" type="submit" id="%2$s" class="%3$s" value="%4$s" /> <a href="#" class="cancel-update-comment gutter gutter-left gutter-sm"><small>' . __('Cancel', 'municipio') . '</small></a>'
        );

        ob_start();
        comment_form($args, $postId);
        $form = ob_get_clean();
        $form = str_replace('class="comment-respond"', 'class="comment-respond comment-respond-new comment-update"', $form);
        $form = str_replace('id="respond"', 'id="respond-edit"', $form);

        wp_send_json_success($form);
    }
public function getCommentForm()
    {
        $postId = $_POST['postId'] ?? null;
        $commentId = $_POST['commentId'] ?? null;

        if (!$commentId || !$postId || !$comment = get_comment($commentId)) {
            wp_send_json_error('Missing variables');
        }

        if (!$comment = get_comment($commentId)) {
            wp_send_json_error('Comment is missing');
        }

        $args = array(
            'id_form' => 'commentupdate',
            'class_submit' => 'btn btn-sm btn-primary',
            'title_reply' => '',
            'title_reply_before' => '',
            'title_reply_after' => '',
            'label_submit' => __('Update', 'municipio'),
            'logged_in_as' => '',
            'comment_field' => '<textarea id="update-comment" name="comment" cols="45" rows="8" aria-required="true">' . $comment->comment_content . '</textarea>',
            'comment_notes_after' => '<input type="hidden" name="commentId" value="' . $commentId . '">
            <input type="hidden" name="nonce" value="' . wp_create_nonce("update-comment_$commentId") . '">',
            'submit_button' => '<input name="%1$s" type="submit" id="%2$s" class="%3$s" value="%4$s" /> <a href="#" class="cancel-update-comment gutter gutter-left gutter-sm"><small>' . __('Cancel', 'municipio') . '</small></a>'
        );

        ob_start();
        comment_form($args, $postId);
        $form = ob_get_clean();
        $form = str_replace('class="comment-respond"', 'class="comment-respond comment-respond-new comment-update"', $form);
        $form = str_replace('id="respond"', 'id="respond-edit"', $form);

        wp_send_json_success($form);
    }
public function getCommentForm ( ) { $ postId = $ _POST [ 'postId' ] ?? null ; $ commentId = $ _POST [ 'commentId' ] ?? null ; if ( ! $ commentId || ! $ postId || ! $ comment = get_comment ( $ commentId ) ) { wp_send_json_error ( 'Missing variables' ) ; } if ( ! $ comment = get_comment ( $ commentId ) ) { wp_send_json_error ( 'Comment is missing' ) ; } $ args = array ( 'id_form' => 'commentupdate' , 'class_submit' => 'btn btn-sm btn-primary' , 'title_reply' => '' , 'title_reply_before' => '' , 'title_reply_after' => '' , 'label_submit' => __ ( 'Update' , 'municipio' ) , 'logged_in_as' => '' , 'comment_field' => '<textarea id="update-comment" name="comment" cols="45" rows="8" aria-required="true">' . $ comment -> comment_content . '</textarea>' , 'comment_notes_after' => '<input type="hidden" name="commentId" value="' . $ commentId . '">
            <input type="hidden" name="nonce" value="' . wp_create_nonce ( "update-comment_$commentId" ) . '">' , 'submit_button' => '<input name="%1$s" type="submit" id="%2$s" class="%3$s" value="%4$s" /> <a href="#" class="cancel-update-comment gutter gutter-left gutter-sm"><small>' . __ ( 'Cancel' , 'municipio' ) . '</small></a>' ) ; ob_start ( ) ; comment_form ( $ args , $ postId ) ; $ form = ob_get_clean ( ) ; $ form = str_replace ( 'class="comment-respond"' , 'class="comment-respond comment-respond-new comment-update"' , $ form ) ; $ form = str_replace ( 'id="respond"' , 'id="respond-edit"' , $ form ) ; wp_send_json_success ( $ form ) ; }
Returns markup for the edit comment form
@return void
Returns markup for the edit comment form