Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions changelog/fix-lesson-comments-visible-to-unregistered-users
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: fixed

Fix lesson comments being visible to unregistered users in some cases
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public function handle_request() {
add_filter( 'template_include', array( $this, 'force_page_template' ) );

// Disable comments if not block theme and post type is not lesson.
if ( ! $this->is_lesson_cpt_in_block_fse_theme() ) {
if ( ! $this->should_show_comments() ) {
Sensei_Unsupported_Theme_Handler_Utils::disable_comments();
}

Expand Down Expand Up @@ -121,7 +121,7 @@ public function cpt_page_content_filter( $content ) {
$content = $renderer->render();

// Disable theme comments.
if ( ! $this->is_lesson_cpt_in_block_fse_theme() ) {
if ( ! $this->should_show_comments() ) {
Sensei_Unsupported_Theme_Handler_Utils::disable_comments();
}

Expand Down Expand Up @@ -247,4 +247,19 @@ public function force_page_template( $template ) {
private function is_lesson_cpt_in_block_fse_theme() {
return 'lesson' === $this->post_type && Sensei_Utils::is_fse_theme();
}

/**
* Determine if comments should be shown.
*
* Comments are only shown for lessons in block themes if the user can view
* the lesson.
*
* @since $$next-version$$
*
* @return bool
*/
private function should_show_comments(): bool {
return $this->is_lesson_cpt_in_block_fse_theme()
&& sensei_can_user_view_lesson();
}
}
Loading