WP Manifestindependent plugin directory
manifest / social / hm-social-share-links

HM Social Links

WordPress Social Share Link's built on top of core social link buttons block and block bindings.

by Human Made · github.com/humanmade/hm-social-share-links · website

★ 0stars
0forks

Install

No release zip yet. The repository archive installs, but the folder name will carry the branch suffix and updates will not flow:

wp plugin install https://github.com/humanmade/hm-social-share-links/archive/refs/heads/main.zip

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, whose get_value_callback builds a share URL for the current post from a network arg (inc/namespace.php).
  • Adds core/social-link's url attribute 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) — a core/social-links block with icons already bound to networks — registered under the "Social Links" pattern category.

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.

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 network keys below, with a metadata.bindings.url pointing at hm-social-links/share-link and that same key as the network 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 networks with the hm_social_links_networks filter rather than editing the plugin:

add_filter( 'hm_social_links_networks', function ( array $networks, string $url, string $title, int $post_id ) {
    $networks['telegram'] = 'https://t.me/share/url?url=' . rawurlencode( $url ) . '&text=' . rawurlencode( $title );
    unset( $networks['pinterest'] );
    return $networks;
}, 10, 4 );

Network keys should match a core/social-link service slug so the same key 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+