Wp-discourse-shortcodes plugin

(Simon Cossar) #22

I have a fix for sending the prefilled message to only the group owner. For now, the fix is only in this branch: GitHub - scossar/wp-discourse-shortcodes at 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.

(Steven Greco) #23

Thanks for doing that, will load it up.

(Lea-Ann McGregor) #24

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

(Simon Cossar) #25

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.

(Brendan Schlagel) #26

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?

(Simon Cossar) #27

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.

(Michel) #28

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.

(Simon Cossar) #29

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.

(Steven Greco) #30

@Simon_Cossar 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"]

(Steven Greco) #31

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

(Simon Cossar) #32

Are you using any of the plugin’s shortcodes other than the discourse_groups shortcode?

(Steven Greco) #33

yes the latest topics one as well

(Simon Cossar) #34

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.

(Steven Greco) #35

yes saw that. Thanks.

(Simon Cossar) #36

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.

GitHub - scossar/wp-discourse-shortcodes at beta-refactor

(Steven Greco) #37

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.

(Simon Cossar) #38

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.

(Steven Greco) #39

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

(Simon Cossar) #40

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 GitHub - scossar/wp-discourse-shortcodes: Extends the wp-discourse plugin by adding shortcodes that can be used to link to the Discourse forum.. 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.

(Erlend Sogge Heggen) #41

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

This plugin is under development. Don’t install it on a live site.

Optimizing Performance for Non Logged In Users on Mobile