| @@ -144,14 +144,10 @@ | ||
| 144 | 144 | return null; |
| 145 | 145 | } |
| 146 | 146 | |
| 147 | 147 | $newComment = Comment::create($commentData); |
| 148 | + Feed::withoutGlobalScopes()->where('id', $feed->id)->increment('comments_count'); | |
| 148 | 149 | |
| 149 | - // A held comment is not visible yet, so it must not be counted until it is approved. | |
| 150 | - if ($newComment->status === 'published') { | |
| 151 | - Feed::withoutGlobalScopes()->where('id', $feed->id)->increment('comments_count'); | |
| 152 | - } | |
| 153 | - | |
| 154 | 150 | return $newComment; |
| 155 | 151 | }); |
| 156 | 152 | |
| 157 | 153 | if (!$comment) { |
| @@ -159,11 +155,9 @@ | ||
| 159 | 155 | 'message' => __('No duplicate comment please!', 'fluent-community') |
| 160 | 156 | ]); |
| 161 | 157 | } |
| 162 | 158 | |
| 163 | - if ($comment->status === 'published') { | |
| 164 | - $feed->comments_count = $feed->comments_count + 1; | |
| 165 | - } | |
| 159 | + $feed->comments_count = $feed->comments_count + 1; | |
| 166 | 160 | |
| 167 | 161 | |
| 168 | 162 | // Merge and save all media in one loop |
| 169 | 163 | $mediaItems = $mediaItems ? (is_array($mediaItems) ? $mediaItems : [$mediaItems]) : []; |
| @@ -619,11 +613,9 @@ | ||
| 619 | 613 | } |
| 620 | 614 | |
| 621 | 615 | $comment->delete(); |
| 622 | 616 | |
| 623 | - $feed->comments_count = Comment::where('post_id', $feed->id) | |
| 624 | - ->where('status', 'published') | |
| 625 | - ->count(); | |
| 617 | + $feed->comments_count = Comment::where('post_id', $feed->id)->count(); | |
| 626 | 618 | $feed->timestamps = false; // Don't update the updated_at timestamp |
| 627 | 619 | $feed->save(); |
| 628 | 620 | |
| 629 | 621 | do_action('fluent_community/comment_deleted_' . $feed->type, $commentId, $feed); |