Within the code at class-syn-link-domain-icon-map.php, I added the following two lines to the obvious spot in the list within the code to fix the icon issues I was having:
'chrisaldrich.wordpress.com' => 'wordpress',
'reading.am' => 'book',
I then reuploaded the edited file to my server. Essentially I’m hard-coding the domain name and the default icon I’d like to have the plugin display.
If the plugin is updated, I’ll obviously have to manually add them again, but the disappearance of the icons again will be pretty obvious and this post will document the necessary changes.
Although upon tweaking this I’m noticing that the reading.am icon isn’t working (I also tried ‘website’ instead of ‘book’ but that didn’t work either). Perhaps the .am tld is causing an issue? Alas…
I suspect that there’s some other bug hiding in the works as one or both of the two types of links above should default to the generic ‘website’ icon when a syndication link exists, but the system isn’t able to specify a particular icon. There may be some small if/else bug hiding in the logic of the plugin.
So I went back in today and explicitly added ‘www’ to make it
'www.reading.am' => 'book',
and that seemed to fix the icon problem. Now to find the piece of code that specifies the hover text for the icon and fix that too.I’d need to spend some time looking into this to confirm either way, but my gut tells me you should be able to use the
syn_link_mapping
filter and a function to make these tweaks via your theme’sfunctions.php
file, without hacking the plugin code itself.I want to do something similar for my Mastodon profile link, so I’ll try to take a look into it in the next couple of days 😃My gut was right 😃. You can add extra icons without editing the plugin, by adding something similar to this to your theme’s
functions.php
function wp4632_extra_site_icons( $return, $url) {
$sites = array(
‘chrisaldrich.wordpress.com’ => ‘wordpress’,
‘www.reading.am’ => ‘book’,
);
$parsed = parse_url( $url );
$return = false;
if ( false !== $parsed ) {
$host = $parsed[‘host’];
if ( array_key_exists( $host, $sites ) ) {
$return = $sites[ $host ];
}
}
return $return;
}
add_filter( ‘syn_link_mapping’, ‘wp4632_extra_site_icons’, 10, 2);
For maximum upgrade safety, I put modifications like this into a child theme.Without similar code in my theme, this post doesn’t display the (test) Mastodon syndication link… but with it the link and icon are displayed. The
$sites
array can be modified with any URLs you want mapped to a suitable icon in the set.Hope this helps you out!Some further notes:
I also noticed that I didn’t have a Hypothes.is svg icon for syndicating there. So I swiped the habr icon from the plugin’s svg folder and copied it as a new file with the name hypothesis and changed the title attribute from within the file. I then added a hypothesis line to
includes/simple-icons.php
and the appropriate line (as above) inincludes/class-syn-link-domain-icon-map.php
. This seems to work a charm, though I may go back and use Chris’ alternate example so I don’t need to rec0de for every plugin update.These should work temporarily until I can get the appropriate .svg files and create a PR for the plugin directly.
Got the Hypothes.is part sorted earlier tonight: https://boffosocko.com/2019/12/01/hypothesis-logo/#comment-271732
Love this. My question, though. How does one get reading.am to work? I have tried to find a way to have all of my reads go to my site as such, but even with the Chrome extension, haven’t figured it out yet. I won’t proceed with this until the bugs are fixed.
Katherine, typically I use a third party service along the lines of Zapier, IFTTT, or Automate.io, to pull in RSS feeds from services like Reading.am into my site in a simple/automated way. There are also various Hooks one can also use within their service if you want to customize things.
Looks like David Shanske’s new version of Syndication Links plugin has fixed most of the small issues that had appeared above, but I’ll leave the post up as an example for those who have edge cases that may be an issue until fixes for them are pushed.