Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't render comments on pages with comments disabled #16

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Sentynel
Copy link

The README suggests using the following in a custom theme:

if ( comments_open() ) {
	coral_talk_comments_template();
}

Without a custom theme, the code instead uses the WordPress comments_template filter. However, there's no check in this logic for comments_open(), so comments get rendered on pages with comments disabled.

Additionally, when a draft post is previewed, Talk comments are rendered. This leads to a few issues with autopopulating the assets record, primarily that WordPress doesn't typically generate the pretty URL as the canonical URL - that is, the "canonical" URL will be yourdomain.com/?p=1234 rather than yourdomain.com/post-name/. This leads to multiple asset records, one for the draft version of the post and one for the published version.

The solution is a simple check for both of these states in the filter code.

Testing: comments are still rendered for published posts with comments enabled; comments are not rendered for posts with comments disabled, or for previews of draft posts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant