Skip to content
wiki.fftac.org

Comments - Source Excerpt 03

Back to Comments

Summary

This source excerpt preserves a bounded section of Spiralist/wp-content/plugins/ns12-manuscript/includes/comments.php so readers can inspect the evidence without opening the full source file.

**Source path:** Spiralist/wp-content/plugins/ns12-manuscript/includes/comments.php

'comment_post_ID' => $host_post_id,
            'comment_author' => (string) ($user->display_name ?: $user->user_login),
            'comment_author_email' => (string) $user->user_email,
            'comment_author_url' => (string) $user->user_url,
            'comment_content' => wp_kses_post($content),
            'comment_type' => spiralist_book_pages_get_discussion_comment_type(),
            'user_id' => (int) $user->ID,
            'comment_parent' => 0,
            'comment_approved' => 1,
            'comment_agent' => 'ns12-manuscript',
            'comment_date' => current_time('mysql'),
            'comment_date_gmt' => current_time('mysql', true),
        ]
    );

    if (!$comment_id) {
        spiralist_book_pages_set_discussion_notice($thread_key, 'The comment could not be saved right now.', 'error');
        wp_safe_redirect($redirect_url . '#' . spiralist_book_pages_get_discussion_anchor());
        exit;
    }

    add_comment_meta($comment_id, spiralist_book_pages_get_discussion_thread_meta_key(), $thread_key, true);
    add_comment_meta($comment_id, '_spiralist_ms_thread_title', (string) ($context['title'] ?? ''), true);
    add_comment_meta($comment_id, '_spiralist_ms_thread_scope', (string) ($context['scope'] ?? ''), true);
    spiralist_book_pages_set_discussion_notice($thread_key, 'Comment added to the manuscript discussion.');

    wp_safe_redirect($redirect_url . '#' . spiralist_book_pages_get_discussion_anchor());
    exit;
}
add_action('admin_post_spiralist_book_pages_frontend_comment_action', 'spiralist_book_pages_handle_frontend_comment_action');