humanmade / hm-social-share-links
Wires the core Social Links block up to dynamic, per-page share-intent URLs (Facebook, X, LinkedIn, WhatsApp, Reddit, Pinterest, email) via the Block Bindings API, plus a ready-made pattern to insert them.
Package info
github.com/humanmade/hm-social-share-links
Type:wordpress-plugin
pkg:composer/humanmade/hm-social-share-links
Requires
- php: >=7.4
- composer/installers: ^1 || ^2
Requires (Dev)
None
Suggests
None
Provides
None
Conflicts
None
Replaces
None
This package is auto-updated.
Last update: 2026-10-02 13:55:03 UTC
README
Wires the core Social Links block up to dynamic, per-page share-intent URLs (Facebook, X, LinkedIn, WhatsApp, Reddit, Pinterest, email) using the Block Bindings API — no custom block, no build step.
How it works
- Registers a block bindings source,
hm-social-links/share-link, whoseget_value_callbackbuilds a share URL for the current post from aservicearg (inc/namespace.php). - Adds
core/social-link'surlattribute to the editor's supported binding attributes (WP 6.9+), so the block shows the native connected/locked state instead of a plain editable field. - Ships a pattern (
patterns/share-links.php) — acore/social-linksblock with icons already bound to services — registered under the "Social Links" pattern category. - Registers the same binding source client-side (
assets/editor.js), so bound URLs resolve against the post being edited rather than showing an empty connected field, and adds a Social Link variation per service to the inserter. It's plain browser JS against thewp.*globals — no build step.
Front-end resolution works from WP 6.5 (block bindings apply at render time regardless of editor support); the 6.9 attribute filter only affects the editor's UI/locking behaviour.
Install
Not on Packagist, so add the repository alongside the require:
{
"repositories": [
{
"type": "vcs",
"url": "https://github.com/humanmade/hm-social-share-links"
}
]
}
composer require humanmade/hm-social-share-links
Usage
Activate the plugin, then insert the "Share Links" pattern from the block
inserter. Add, remove, or reorder icons as normal — each core/social-link
block just needs a service matching one of the service keys below, with a
metadata.bindings.url pointing at hm-social-links/share-link and that
same key as the service arg.
Local testing (WordPress Playground)
No local PHP/MySQL/Docker needed — WordPress Playground runs WordPress in-process via WASM.
npm install npm run playground:start
This mounts the working directory as an active plugin (--auto-mount), on
WP latest, landing straight in the post editor so you can insert the
pattern and check the bound URLs. Config lives in blueprint.json.
The README badge above uses a second file, blueprint-demo.json — it can't
use --auto-mount (there's no local filesystem in a browser), so it
installs the plugin from a zip of this repo's main branch instead. It only
works once this repo is pushed to humanmade/hm-social-share-links and
blueprint-demo.json is present on main, since Playground fetches it live
from raw.githubusercontent.com.
Extending
Add, remove, or override services with the hm_social_links_services
filter rather than editing the plugin:
add_filter( 'hm_social_links_services', function ( array $services ) { $services['telegram'] = [ 'label' => __( 'Share on Telegram', 'my-theme' ), 'template' => 'https://t.me/share/url?url={url}&text={title}', ]; unset( $services['pinterest'] ); return $services; } );
{url} and {title} are replaced with the rawurlencoded post permalink and
title. The same template drives the front end and the editor, so the two
can't disagree — and a service added here gets an inserter variation too.
Each key is the core/social-link service slug it applies to, which is
what drives both the icon and the bound URL.
Requirements
- WordPress 6.9+ (for the editor-side connected/locked UI; render-time binding resolution works from 6.5)
- PHP 7.4+