| @@ -28,9 +28,18 @@ | ||
| 28 | 28 | 'message' => __('Sorry, you do not have permission to view this post', 'fluent-community') |
| 29 | 29 | ], 404); |
| 30 | 30 | } |
| 31 | 31 | |
| 32 | - $canViewComments = apply_filters('fluent_community/can_view_comments_' . $feed->type, true, $feed); | |
| 32 | + /* | |
| 33 | + * The row's own setting is the default the filter gets handed, rather than a bare | |
| 34 | + * true. Before this, meta.enable_comments was read nowhere on this path, so a page | |
| 35 | + * with comments switched off still served its thread to anyone who asked for it. | |
| 36 | + */ | |
| 37 | + $canViewComments = apply_filters( | |
| 38 | + 'fluent_community/can_view_comments_' . $feed->type, | |
| 39 | + FeedsHelper::commentsEnabled($feed), | |
| 40 | + $feed | |
| 41 | + ); | |
| 33 | 42 | |
| 34 | 43 | if (!$canViewComments) { |
| 35 | 44 | return [ |
| 36 | 45 | 'comments' => [] |
| @@ -431,9 +440,9 @@ | ||
| 431 | 440 | } |
| 432 | 441 | |
| 433 | 442 | private function validateCommentText($data) |
| 434 | 443 | { |
| 435 | - $text = trim(Arr::get($data, 'comment')); | |
| 444 | + $text = trim((string) Arr::get($data, 'comment', '')); | |
| 436 | 445 | $text = CustomSanitizer::unslashMarkdown($text); |
| 437 | 446 | |
| 438 | 447 | // Decode HTML entities (e.g.,   for space) and strip all whitespace for validation |
| 439 | 448 | $textForValidation = html_entity_decode($text, ENT_QUOTES | ENT_HTML5, 'UTF-8'); |
| @@ -460,9 +469,9 @@ | ||
| 460 | 469 | } |
| 461 | 470 | |
| 462 | 471 | private function verifyCreateCommentPermission($feed) |
| 463 | 472 | { |
| 464 | - if (Arr::get($feed->meta, 'comments_disabled') === 'yes') { | |
| 473 | + if (!FeedsHelper::commentsEnabled($feed)) { | |
| 465 | 474 | throw new \Exception(esc_html__('Comments are disabled for this post', 'fluent-community')); |
| 466 | 475 | } |
| 467 | 476 | |
| 468 | 477 | $this->verifySpacePermission($feed); |