A few enhancements for the wp-discourse plugin


(pjv) #1

I鈥檝e put a few pull requests into the hopper on github for the wp-discourse plugin that fix a bug and add a couple minor features to the plugin to fit how I want to use it as I have been integrating Discourse into an existing WordPress site that I manage. I thought I would post a little summary about them here.

  1. In the HTML template for each comment there is a comment-meta item that is the datetime for when the comment was posted. That data is supposed to be wrapped with an HTML <time> tag. But that tag is not on WordPress鈥檚 global list of allowed tags and so it was getting filtered out of the HTML that was being output on the front end. I just added the <time> tag to the list of allowed tags for the sake of the wp-discourse plugin to fix this. See: add <time> tag to WP allowed html tags by pjv 路 Pull Request #135 路 discourse/wp-discourse 路 GitHub

  2. The way the plugin was formatting the datetime from the Discourse comment, it was only using the format string for a date from the WP site鈥檚 preferences. So the datetime was only a date (no time). I added a new custom datetime format string to the admin that allows you to format the datetime string however you want, consistent with WordPress datetime formatting options. See: add custom datetime format string to admin settings by pjv 路 Pull Request #136 路 discourse/wp-discourse 路 GitHub

  3. The last one is my answer to what to do about enabling Discourse comments for existing WP posts/pages that have a lot of valuable pre-existing WP comments on them. It would be nice to be able to cleanly export WP comments into Discourse, but there is no currently existing importer for standard WP comments and there are a lot of edge cases that make developing one too big a chore for me. The current behavior of the wp-discourse plugin makes you choose to either show Discourse comments and hide the old WP comments OR show the WP comments and not show the Discourse comments. This patch lets you enable Discourse comments for existing posts and choose to show the existing WP comments as a 鈥渉istorical archive鈥 beneath the new Discourse comments. See: Allow showing existing WP comments under Discourse by pjv 路 Pull Request #137 路 discourse/wp-discourse 路 GitHub


WordPress Integration Guide
(pjv) #2

And another one - using code from @AdamCapriola, for those using the SSO feature, I added a feature that lets you fill in the logout redirect field in the Discourse admin with a URL that will be handled by the wp-discourse plugin and will automatically log you out of WordPress when you log out of Discourse. Its use is entirely optional - if you don鈥檛 put the specific URL into the Discourse admin, then you are not logged out of WordPress (which is the standard behavior of the plugin). See: log out of WP when log out of Discourse by pjv 路 Pull Request #158 路 discourse/wp-discourse 路 GitHub