| 开发者 | dshanske |
|---|---|
| 更新时间 | 2026年11月10日 02:05 |
| PHP版本: | 7.4 及以上 |
| WordPress版本: | 7.1 |
| 版权: | GPLv2 or later |
Declare support in the theme's functions.php, on after_setup_theme like other theme features:
add_theme_support( 'syndication-links' );
The plugin then stops adding the links after the post content and after each comment, and the settings page says the theme places them. To take over only one of them, list it: add_theme_support( 'syndication-links', array( 'content' ) ) or array( 'comments' ).
Then output the links where the theme wants them with get_post_syndication_links() and get_comment_syndication_links(). The display settings (icons or text, size, text before the links) still apply.
The older filters still work, and are now checked when the links would be added, so it doesn't matter when they're added: add_filter( 'syndication_links_display', '__return_false' ); for the post content, and syndication_links_comment_display for comments.
get_comment_syndication_links( $comment, $args ) - Returns the HTML for a comment. ** $args ***style- Defaults to ul ***text- Display text, defaults to settings option ***icons- Display icons, defaults to settings option ***container-css- Class to wrap entire syndication links in ***single-css- Class to wrap a single link in ***text-css- Class to wrap the text before the links in ***targets` - Whether to add Bridgy targets as empty links, which Bridgy looks for on the post's page. Defaults to truethe_syndication_links( $post, $args ) and the_comment_syndication_links( $comment, $args ) display the links. get_post_syndication_links() and get_comment_syndication_links() return them instead.syndication_links_display_mode() returns how links are shown on the current page: icons, text, iconstext or hidden.Many themes have their own hooks, such as Genesis's genesis_entry_footer. To show the links there instead of after the content, add this to a child theme's functions.php, or to a small plugin:
add_action( 'after_setup_theme', function () { add_theme_support( 'syndication-links', array( 'content' ) ); } );
add_action( 'genesis_entry_footer', function () { the_syndication_links(); } );
The first line stops the plugin adding the links after the content. The second shows them on the theme's hook; use whichever hook your theme offers. the_syndication_links() is new in 5.0.0. Keep the links inside the post's h-entry markup, so they're still read as its syndication links.
If you add ?original-of= and the URL-encoded URL it will return the post that has that URL stored. As no two posts should have the same two syndication links it will by default only return the first.
If you want to do this with a form, there is a function you can add to your theme called get_original_of_form() and a widget that calls this. Like the search form if you have a
originalofform.php in your theme folder the function will return it so you can customize the form.
Add ?syndication= and a domain, such as ?syndication=mastodon.social, to your site's address. It lists the posts with a syndication link to that domain. A full URL works too: its domain is used.
It combines with WordPress's other query parameters, so ?syndication=mastodon.social&s=widgets searches those posts for "widgets".
The plugin bundles icons for about 80 services: the common social networks, the Fediverse, the sites it can syndicate to, and the networks other cross-posting plugins post to, plus icons for retired services such as Google+ that old posts still link to. A link to any other site shows the generic website icon.
The Icons tab of the settings page lists the sites your posts and comments link to that show the generic icon, with how many links each has (or run wp syndication-links icons missing). From there you can check them for Fediverse software, which links saved before 5.0.0 haven't had, and report any of them: Report opens a GitHub issue with the domain filled in, for you to send. If Simple Icons has a site's icon, Add next to it downloads it. The icon comes from the same Simple Icons release as the bundled ones and is stored in your uploads folder (wp syndication-links icons add <name> does the same). To have matching icons added as links are saved, turn on the "Add Icons Automatically" setting. You can also open an issue yourself with the domain and, if it has one, its Simple Icons name.
To add an icon on your own site, put an SVG named after the domain (example.svg for example.com) in a directory and add it to the search list:
add_filter( 'syn_icon_file_dirs', function ( $dirs ) { $dirs[] = get_stylesheet_directory() . '/icons'; return $dirs; } );
Use the syn_link_title filter for its name and syn_link_icon_color for its colour, or syn_link_mapping to point a domain at an icon with a different name.
Fediverse servers run on any domain. When a link to a site without a known icon is saved, the plugin asks that site in the background which software it runs, and shows its icon: Mastodon, Pixelfed, PeerTube, Lemmy, Misskey and others, or the ActivityPub icon for software without one. Until that check has run, or if it's turned off with the "Detect Fediverse Servers" setting, the plugin also uses the Mastodon icon for:
mastodon user field, which the IndieWeb plugin adds as "Mastodon Server (URL)". Enter your profile URL, such as https://masto.ai/@username.mastodon.social or mastodon.online, which match the icon by name.syn_link_mapping filter to return mastodon for any URL.
syn_rewrite_secure( $domains ) - $domains is an array of domain names to rewrite to https if foundsyn_metabox_types( $screens ) - $screens would be an array of post types to add the Syndication Link metabox to.syn_add_links( $urls, $post_ID ) - (Deprecated) $urls is an array of retrieved links from $post_IDget_post_syndication_links( $urls, $post_ID) - Replaces syn_add_links.get_comment_syndication_links( $urls, $comment_ID - Filters an array of retrieved comment syndication links.syn_links_display_defaults( $defaults ) - Filter the defaults for displaying Syndication Linkssyndication_link_checked( $checked, $uid, $post_ID ) - Will check a syndication provider($uid) when loaded. The post ID is passed through to allow more specific targeting.syndication_link_disabled( $disabled, $uid, $post_ID ) - Will disable the checkbox for a syndication provider($uid) when loaded. The post ID is passed through to allow more specific targeting.syn_link_title( $title, $name ) - Allows you to set the title string for Links. Example, pinboard => Pinboard.syn_link_mapping( $icon, $url ) - Allows you to override or set the mapping from URL to icon name.syn_link_rel( $rels, $url ) - The rel values of a syndication link: nofollow, plus syndication on a single post's page. Remove nofollow to let search engines follow the links.pre_syn_link_icon( $icon, $name ) - Allows you to provide a custom icon. Icons by default are SVG, not URL or filenames.syn_link_fediverse_software( $map ) - The icons for Fediverse software, keyed by the lowercase software name a server reports in its NodeInfo, such as 'akkoma' => 'pleroma'. Software that isn't listed gets the ActivityPub icon if it speaks ActivityPub.syn_link_icon_color( $color, $name ) - An icon's brand colour as a hex value such as #1185FE, or null for none (the icon then takes the link's colour). Use it to colour an icon you've added. Output as the --syn-icon-color CSS custom property.syndication_links_display( true ) - Adds Syndication Links to content display. Set to false if the theme supports this, or declare add_theme_support( 'syndication-links' ).syndication_links_comment_display( true ) - Adds Syndication Links after each comment. Set to false if the theme places them.syndication_links_feed_display( true, $feed_type, $post_id ) - Whether a feed shows the post's links: after the content in RSS and Atom, and as syndication in JSON Feed. The Micro.blog provider turns them off in its own feed.syndication_links_delete_copies( $copies, $post ) - The copies deleted when a post is trashed or deleted: their URLs, keyed by provider UID. Return an empty array to keep them.Development and bug reports on this plugin is on Github at https://github.com/dshanske/syndication-links
syn_link_title filter that returns HTML now has it escaped. Text before the links still allows formatting such as <em>.post, are sent when they're queued and published (props @kupietools).wp syndication-links import command: copy the links recorded by other cross-posting plugins (SNAP, Mastodon Autopost, XPoster, Autopost for X, Keyring, Medium) into the post's own syndication links. Once imported, the other plugin can be removed without losing the links. Other plugins can add import sources with register_syndication_link_source().add_theme_support( 'syndication-links' ), for the post content, comments or both. The syndication_links_display filter now works whenever it's added, and the new syndication_links_comment_display filter does the same for comments.mastodon profile field works again, and the list is refreshed daily and when a profile changes.mf2_syndication) and the syndication log no longer appear in the Custom Fields box. The meta keys are unchanged.?original-of= matches the exact link, searches every syndication post type, and returns a 404 when nothing matches. ?syndication= only filters the main query.mailto:, sms: and tel: links get mail and phone icons.rel="nofollow". The new syn_link_rel filter can remove it.the_syndication_links(), the_comment_syndication_links() and syndication_links_display_mode().syndication_urls links are moved to mf2_syndication in the background instead of when a post is read.syndication field is never an object.syndication_links_delete_copies.WP_DEBUG on, syndication logs a one-line summary instead of the full response.bsky.social, such as someone.bsky.social, show the Bluesky icon.wp syndication-links icons add <name> and icons remove. They're stored in uploads/syndication-links/icons/, pinned to the bundled Simple Icons release.wp syndication-links icons missing: the linked sites that show the generic icon, with link counts, a Fediverse check for links saved before, and a Report link that opens a prefilled icon request on GitHub.syn_link_fediverse_software filter.svg-{name} class for styling, instead of its name as text. The generic icons were missing from the WordPress.org release, so icons-only mode showed "website" as text. Only the Genericons Neue icons in use (website, notice, book, summary, mail, phone) are bundled now.syndication_links_feed_display filter can turn them off in any feed.syn-medium, syn-large, syn-bw* and syn-minimal stylesheets are removed. New syn_link_icon_color filter.max-width held every icon at the small size. Icon size and spacing now come from the stylesheet only. Icons no longer carry a <title>, which showed a second tooltip, and the BookWyrm icon is no longer cut off.pre_syndication_links_webmention hook to allow you to clear cache before sending webmention.syn_link_name filter that allows you to set the name string.pre_syn_link_icon filter to allow short circuiting the domain mapping and providing an SVG of your choice.get_original_of_form() which creates a search for for the original of query which looks up posts by their syndication link