'.esc_html($comment['body']).'
settings->ready() && $post && $post->post_status === 'publish' && in_array($post->post_type, $this->settings->all()['post_types'], true) && !post_password_required($post) && !is_feed() && !is_preview() && !is_admin(); } public function thread(WP_Post $post): string { $saved = get_post_meta($post->ID, '_kommentti_thread_id', true); return is_string($saved) && $saved !== '' ? $saved : (string) $post->ID; } public function render(?WP_Post $post = null): string { $post ??= get_post(); if ($this->rendered || !$this->eligible($post) || !is_singular() || (int) get_queried_object_id() !== $post->ID) { return ''; } $this->rendered = true; $settings = $this->settings->all(); $thread = $this->thread($post); // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Public read-only pagination must also work for crawlers. $page = filter_var(wp_unslash($_GET['comments_page'] ?? 1), FILTER_VALIDATE_INT, ['options' => ['min_range' => 1, 'max_range' => 10000]]) ?: 1; $snapshot = $settings['mode'] === 'server' ? $this->api->comments($post->ID, $thread, $page) : null; $readOnly = !comments_open($post->ID); $this->embed = ['data-site' => $settings['site_id'], 'data-thread' => $thread, 'data-target' => 'kommentti-comments', 'data-locale' => $this->settings->locale(), 'data-readonly' => $readOnly ? 'true' : 'false']; if ($snapshot !== null) { $this->embed += ['data-view' => 'composer', 'data-render-target' => 'kommentti-server-comments']; } wp_enqueue_style('kommentti-publisher'); wp_enqueue_script('kommentti-embed'); ob_start(); if (!wp_style_is('kommentti-publisher', 'done')) { wp_print_styles(['kommentti-publisher']); } echo '
'.esc_html__('Comments', 'kommentti').': '.(int) $snapshot['total'].'
'.esc_html($comment['body']).'
'.esc_html($labels['empty']).'
'; if ($snapshot['page'] > 1 || $snapshot['has_more']) { $html .= ''; } return $html.'
'.esc_html__('Comments', 'kommentti').'
'; if ($snapshot !== null) { // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- markup() escapes every dynamic HTML value. echo $this->markup($snapshot, get_permalink($post), $readOnly || $snapshot['locked']); } echo '