PRC's override/extension of the WordPress core/social-links and core/social-link blocks.
Block Namespace
prc-block/core-social-links
What PRC Customizes
- Adds
title,description,url,imageId, andhashtagsattributes tocore/social-links - Provides block context from parent
core/social-linksto childcore/social-linkblocks - Registers "Print" and "Bookmark" as custom social services with FontAwesome icons
- Falls back to the post shortlink when no URL is provided
- Adds an Interactivity API store (
core/social-links) for client-side share link generation - Supports sharing to Facebook, LinkedIn, Twitter/X, Threads, and Bluesky
- Handles print (navigate to
/printsuffix on the current path), mail (mailto: link), and bookmark actions - Hides the Print link for logged-out users
- Adds a "Share Meta" inspector panel to configure title, description, and URL overrides
- Enables full typography support on the social-links block
- Registers "Pill Shape" style with rounded borders
Supports Modifications
| Support | Change |
|---|---|
typography | Enables fontSize, lineHeight, fontFamily, fontWeight, fontStyle, textTransform, textDecoration, letterSpacing |
Applied via block_type_metadata_settings filter in add_settings.
Additional Attributes
| Attribute | Type | Description |
|---|---|---|
title | text | Override title for social sharing |
description | string | Override description/excerpt for sharing |
url | string | Override URL for sharing (falls back to shortlink) |
imageId | number | Image attachment ID for sharing |
hashtags | array | Array of hashtag strings |
Added via block_type_metadata filter in add_attributes.
Available Styles
| Style Name | Label | Description |
|---|---|---|
pill-shape | Pill Shape | Rounded pill borders with light gray border color |
Defined in style.scss.
Style Overrides
File: style.scss
- Link visited color —
.wp-block-social-link-anchor:visitedinherits color - Pill Shape —
.is-style-pill-shapesetsalign-items: stretch, addsborder-radius: 9999pxand1px solid ui-gray-lightborder on social link anchors and buttons
Editor Enhancements
File: index.js
- HOC wrapping
editor.BlockEditforcore/social-linksto inject theControlscomponent - Registers
printandbookmarkblock variations oncore/social-linkwith FontAwesome icons
File: controls.jsx
- "Share Meta" inspector panel with
TextControlfields for Title, Description, and URL override
Frontend Interactivity
File: view.js (Interactivity API module)
- Registers store
core/social-linkswith:actions.onClick— routes clicks to the appropriate handler based on platformactions.onShareClick— generates platform-specific share URLs and opens a popup window:- Facebook —
facebook.com/sharer/sharer.php?u= - LinkedIn —
linkedin.com/shareArticlewith summary, url, title, source - Twitter/X —
twitter.com/intent/tweetwith text and url - Threads —
threads.net/intent/postwith text - Bluesky —
bsky.app/intent/composewith text
- Facebook —
actions.onPrintClick— appends/printto the current path (strips trailing slashes, removes anypdfquery arg) and navigates there for print/PDF captureactions.onMailClick— opens amailto:link with subject and bodyactions.onBookmarkClick— placeholder for future PRC User Accounts Bookmarks integration
- Falls back to OG meta tags (
og:title,og:description,og:url) when context values are not provided
PHP Rendering
File: class-core-social-links.php
register_assets(inithook) — registers editor script, view script module, and style handlesadd_attributes(block_type_metadatafilter) — addstitle,description,url,imageId,hashtagsattributes tocore/social-linksadd_settings(block_type_metadata_settingsfilter) — configuresprovides_contexton parent block anduses_contextoncore/social-linkchild block; enables full typography supportsocial_links_url_fallback(render_block_datafilter) — falls back towp_get_shortlink()when no URL attribute is setsocial_link_icons(block_core_social_link_get_servicesfilter) — adds "Print" and "Bookmark" social services with SVG iconssocial_links_context_handler(render_block_contextfilter) — populates URL (shortlink fallback), title (post title), and description (post excerpt) context values for child blockssocial_link_render_callback(render_blockfilter oncore/social-link) — hides Print link for logged-out users; adds Interactivity API attributes (data-wp-interactive,data-wp-context,data-wp-on--click) to social link items
Block Markup Example
<ul class="wp-block-social-links is-style-pill-shape">
<li class="wp-social-link wp-social-link-facebook"
data-wp-interactive="core/social-links"
data-wp-context='{"url":"https://pewrsr.ch/abc","title":"Report Title","description":"...","platform":"facebook"}'
data-wp-on--click="actions.onClick">
<a class="wp-block-social-link-anchor" href="">
<svg>...</svg>
<span class="wp-block-social-link-label">Facebook</span>
</a>
</li>
<li class="wp-social-link wp-social-link-print"
data-wp-interactive="core/social-links"
data-wp-context='{"url":"...","title":"...","description":"...","platform":"print"}'
data-wp-on--click="actions.onClick">
<a class="wp-block-social-link-anchor" href="">
<svg>...</svg>
<span class="wp-block-social-link-label">Print</span>
</a>
</li>
</ul>
Variations
| Block | Variation Name | Title | Description |
|---|---|---|---|
core/social-link | print | Opens the /print route for the current page | |
core/social-link | bookmark | Bookmark | Placeholder for future bookmarking |
Registered in index.js via registerBlockVariation.