Wp-discourse-shortcodes plugin

I have a fix for sending the prefilled message to only the group owner. For now, the fix is only in this branch: https://github.com/scossar/wp-discourse-shortcodes/tree/beta-message-group-owner

If there is more than one owner for the group, the message will only be sent to the first owner.

I plan to rework the plugin to use email as the default for the messaging functions.

1 Like

Thanks for doing that, will load it up.

@simon, will the functionality you are building for the membership plugin be compatible with this shortcode plugin??

Yes, both the shortcodes plugin and the one Iā€™m making for memberships extend the wp-discourse plugin, so they can all be used together.

This is great! Thanks Simon. Been looking for a way to embed a few latest posts in Wordpress.

Our use case for this: weā€™re building a membership site and would like to have a list on our main member dashboard that links to a few Discourse discussions members would be most likely to enjoy.

One suggestion: it might be useful to have a [discourse_top] shortcode that works basically the same way as [discourse_latest]. I imagine it would take same params + a ā€œrangeā€ option to specify ā€œtodayā€ / ā€œweekā€ / ā€œmonthā€ / etc.

Iā€™m thinking ā€œtopā€ topics might be more likely to spark engagement than ā€œnewestā€. Though may be cool to display both, actually :slight_smile:

PS ā€” just saw your new ā€œWP Discourse Latest Topicsā€ plugin linked in the WP Discourse 1.2.5 announcement. It seems thatā€™s basically a single feature extracted from this shortcodes plugin, as a demo/test of some sort? For using [discourse_latest] should we stick to using the shortcodes plugin for now?

They are both officially ā€˜Works in Progressā€™. My intention is to rework the wp-discourse-shortcodes plugin by gradually adding shortcodes to it - starting with [discourse_latest]. If anyone wants to use this on a production site, they should get in touch with me.

3 Likes

Simon, for [discourse_latest], if there any reason why we would not be able to get more than 2 latest topics displaying?

Both using the default and using the max_topics parameter leaves it at 2 topics displayed for us.

Iā€™m not sure, I can take a look at it. I havenā€™t done any work on this plugin for quite a while.

Iā€™ve developed a separate plugin for the latest_topics shortcode that allows you to use a Discourse webhook so that topics are updated in real time. That plugin is also going to include a discourse_top shortcode. I need to double-check my work on it. Once Iā€™ve done that Iā€™ll post a link to the code.

2 Likes

@simon I know you have not worked on this in awhile but was wondering if you could help me with an issue with the groups function. If i have an ā€œ@ā€ mention within the description for the group the link is incorrect on my wordpress site. I believe it has to do with the way the link is formatted within Discourse in that it does not include the domain name. When it displays the mention in wordpress it grabs the WordPress site domain instead. Is there a way to rewrite the link so that it has my Discourse domain instead?

Also the invite group buttons donā€™t show up which i think my be a theme issue for me.

This is how i have my shortcode setup.

[discourse_groups group_list="ArkPlayers,BattlefieldPlayers,CODPlayers,DestinyPlayers,DivisionPlayers,ED_Players,ESOPlayers,ForzaPlayers,GTAPlayers,GoWPlayers, GRG_Benefactor,HaloPlayers,OverwatchPlayers,PS4Players,TitanfallPlayers" button_text="Join Now" invite="true"]
1 Like

I did want to add that i am currently just using a redirect rule to pass to the correct page.

Are you using any of the pluginā€™s shortcodes other than the discourse_groups shortcode?

yes the latest topics one as well

Iā€™ve made a new plugin for displaying the latest topics. It uses a webhook for refreshing the topics. Iā€™ve been wondering about moving the groups shortcode into that one. Iā€™ll look at it today.

yes saw that. Thanks.

There are a couple of problems with the current version of this plugin when using the latest Discourse version. Since Discourse has added /groups pages and a group description field, it makes sense to update the plugin to use those.

Hereā€™s a new version of the plugin. It ties into the WP Discourse settings page. For the group links, it defaults to linking to the /groups/group-name page. Thereā€™s an option to send a message to the group if you want the old behaviour. It gets the group_description from the group_description field, instead of requiring you to create a topic for it.

There are no styles added to the displayed groups.

It adds a new version of the latest_topics shortcode that can be updated with a webhook.

This isnā€™t quite ready to be used, but feel free to try it out and let me know if you run into any problems. Iā€™ll try to get back to it later this week. Iā€™m going to add a discourse_top shortcode and a staged_user option to the discourse_prefilled_message shortcode.

https://github.com/scossar/wp-discourse-shortcodes/tree/beta-refactor

2 Likes

Loaded this up and went through it a bit. Works well. I did notice that if there is an image in the description the image does not show up on the WordPress site. Instead it just shows the link to the image.

1 Like

Thatā€™s strange, a description like this one displays correctly in my development setup:

<img src="http://localhost:3000/uploads/default/original/1X/e2395d972cefce63ff99f8b9bc8c3973a6b8e7c3.jpg" />
<p>Walking in and around Nanaimo.</p>

If you change the group description, you need to select the Refresh Discourse Groups checkbox on the Shortcodes tab. It is only enabled for a single request. The UI for this isnā€™t very clear, but it seems like the most efficient way to do it.

2 Likes

Oh my. It did not even occur to me to use the HTML tags. Thanks.

1 Like

Iā€™ve done some work on the discourse_latest shortcode. Itā€™s now called discourse_topics. You can specify which topic list you want with a shortcode attribute. It currently has /latest and /top(daily|monthly|quarterly...) routes. Iā€™ll add a categories route soon. An excerpt can be added to each topic by giving a value to the excerpt_length attribute. If you give it the value ā€˜fullā€™, it will display the full posts. The data and assembled HTML is cached. You can specify the cache_duration for each shortcode. An optional webhook can be used to break the cache for the /latest route. Thereā€™s an option for updating the latest route with ajax.

The position of the category badge, avatar, username, and date can all be set with shortcode attributes. A category class is added to each list item that can be used for styling. The plugin comes with some optional styles. If they are used, adding a tile=true attribute to the shortcode gives a basic tile layout. The size and spacing of the tiles can be altered by adding some css. Overflowing text in the tiles is truncated with javascript.

Iā€™ve also added an RSS shortcode that does basically the same thing, but displays less information. Iā€™m not sure that itā€™s going to make it into the final version of the plugin.

The code is here https://github.com/scossar/wp-discourse-shortcodes. Thereā€™s a messy live demo here https://testeleven.com/. Iā€™ll be working on it some more this week, and also writing some documentation. If anyone would like to try it out in the meantime, bug reports would be greatly appreciated.

2 Likes

Is the plugin safe for production use now? README description says

This plugin is under development. Donā€™t install it on a live site.

2 Likes