janboddez / share-on-mastodon

Easily share WordPress posts on Mastodon.
https://jan.boddez.net/wordpress/share-on-mastodon
GNU General Public License v3.0
39 stars 5 forks source link

Supporting Syndication Links plugin #69

Closed jasontucker closed 1 year ago

jasontucker commented 1 year ago

I'm curious if you have tried the Syndication Links plugin and if you have looked into may supporting it with this plugin? The idea is when a post made on Mastodon the resulting url is saved for this plugin to display on the site. Curious what your thought are on this and if it would be something you could support.

https://wordpress.org/plugins/syndication-links/

Here is how one of the supported plugins is doing it https://github.com/fabacab/wp-crosspost/blob/83df3c04add331d9688f8b24b074c81007a9686c/wp-crosspost.php#L120 and another one (by the same author) https://github.com/fabacab/diasposter/blob/4a39a8b3dbf2a28e7c802f6175b65b4b68221fc8/diasposter.php#L56

Here is a list of plugins supporting this:

SUPPORTED POSSE PLUGINS AND IMPLEMENTATIONS The plugin supports automatically pulling data from plugins that syndicate your content so you don’t need to do it manually. For anything not built in, integation is easy with a simple filter for potential use with any other plugin.

Social Networks Autoposter – Syndication Links supports Twitter, Facebook, and Tumblr since version 1.0.0 Tumblr Crosspostr – Supports Syndication Links since version 0.8.1 WordPress Crossposter – Supports Syndication Links since version 0.3.2 Diasposter – Supports Syndication Links since version 0.1.8 WP-To_Twitter – Supported by the plugin since version 4.2.3

janboddez commented 1 year ago

Did you already give this a try? Provided both plugins are installed?

image

janboddez commented 1 year ago

What that does is, Syndication Links automatically appends this list of syndicated links, and this setting will filter that list, adding in Mastodon links from "Share on Mastodon."

You could do other things using hooks and such, but this is I think the basic functionality you may be looking for.

The other plugin of mine, IndieBlocks, does it the other way around. It comes with a Syndication block (so no auto-appending to post content) that out of the box supports Share on Mastodon/Pixelfed but can be filtered to include Syndication Links or other URLs. (I have to basically rewrite the documentation for all these plugins, but ... time ...)

jasontucker commented 1 year ago

Ah, looks like I was using the released plugin from the plugin directory and not the dev one. 🥇 I'll give this a try and see how it works for me.

janboddez commented 1 year ago

I was sort of convinced this was already in the released version, oops ... I'm way behind with all that stuff. I'll look into it.

janboddez commented 1 year ago

To do: use the newer filter, see also https://github.com/janboddez/indieblocks/issues/85.

$urls = apply_filters( "get_{$type}_syndication_links", $urls, $id );

Means we gotta walk through the different post types, call our callback multiple times.

$options    = get_options();
$post_types = (array) $options['post_types']; // Should make this more robust.

foreach ( $post_types as $post_type ) {
    add_filter( "get_{$post_type}_syndication_links", array( __CLASS__, 'syndication_links' ), 10, 2 );
}
janboddez commented 1 year ago

Fixed in d1107fe.