Contents
Hooks reference - Plugixa Easy Social Share Buttons
The plugin fires 13 actions and 40 filters, all prefixed
plugixa_social_share_. One filter is applied only by Pro and is marked
PRO.
Most of the plugin is built on these same hooks: the networks, the styles, the positions and the settings each module owns all arrive through the filters below. Anything the plugin’s own modules do, your code can do the same way.
The ones you are most likely to want
| Hook | Type | What it is for |
|---|---|---|
plugixa_social_share_networks |
filter | Add, change or remove a share destination |
plugixa_social_share_is_shareable |
filter | Switch automatic buttons off for a class of pages |
plugixa_social_share_placeable_post_types |
filter | Change which post types the wizard offers |
plugixa_social_share_shared_url |
filter | Change the address a network is given to share |
plugixa_social_share_context |
filter | Change the title, text or image being shared |
plugixa_social_share_render |
filter | Change a finished row of buttons |
plugixa_social_share_link_previews_printed_by |
filter | Tell the plugin your theme prints its own Open Graph tags |
Objects passed to hooks
| Class | What it is | Useful public properties |
|---|---|---|
PlugixaSocialShare\Core\Render\Network |
One destination | slug, label, group, color, url, intent, count_source |
PlugixaSocialShare\Core\Render\Context |
What is being shared | post_id, url, title, excerpt, image, via, hashtags, placement |
PlugixaSocialShare\Core\Render\Instance |
A set’s look | id, networks, template, layout, align, counts, total, label, vertical, size, size_mobile, count_pos, total_pos, more, color, ink |
PlugixaSocialShare\Core\Sets\ShareSet |
A saved share set | id, name, instance, placements |
PlugixaSocialShare\Core\Container |
The plugin’s service container | get( Some::class ) |
All of them are read-only objects.
Actions
Lifecycle
plugixa_social_share_fs_loaded
Fires from the plugin’s main file once the Freemius SDK accessor has run,
before plugins_loaded. No parameters.
plugixa_social_share_loaded
Fires once the plugin has finished starting, on plugins_loaded.
| Parameter | Type | Meaning |
|---|---|---|
$container |
PlugixaSocialShare\Core\Container |
The plugin’s service container |
add_action( 'plugixa_social_share_loaded', function ( $container ) {
// The plugin is present and booted.
} );
plugixa_social_share_activated
Fires when the plugin is activated, after its tables, capabilities and default settings are in place. No parameters.
plugixa_social_share_deactivated
Fires when the plugin is deactivated, before its own scheduled events are cleared. Clear your own scheduled events here. No parameters.
add_action( 'plugixa_social_share_deactivated', function () {
wp_clear_scheduled_hook( 'my_addon_task' );
} );
plugixa_social_share_uninstall
Fires once per site at the start of the plugin’s uninstall, before its options and tables are removed. No parameters. The plugin is not booted during an uninstall, so only code that WordPress has loaded at that moment can listen.
Admin and REST
plugixa_social_share_admin_submenus
Fires straight after the plugin registers its admin menu and its Overview submenu, so more submenu pages can be added under it.
| Parameter | Type | Meaning |
|---|---|---|
$slug |
string | The parent menu slug, plugixa-social-share |
$render |
callable | The callback that prints the admin app’s container |
add_action( 'plugixa_social_share_admin_submenus', function ( $slug, $render ) {
add_submenu_page( $slug, 'My page', 'My page', 'manage_options', 'my-page', 'my_page_render' );
}, 10, 2 );
plugixa_social_share_enqueue_assets
Fires on the plugin’s own admin screen, once the app’s scripts are enqueued.
| Parameter | Type | Meaning |
|---|---|---|
$hook_suffix |
string | The admin page being rendered |
plugixa_social_share_register_rest_routes
Fires on rest_api_init, after the plugin has registered its own routes.
| Parameter | Type | Meaning |
|---|---|---|
$namespace |
string | plugixa-social-share/v1 |
$container |
PlugixaSocialShare\Core\Container |
The plugin’s service container |
plugixa_social_share_post_box
Fires inside the classic editor’s Share buttons box, between the “Show” tick box and the list of spots, inside the box’s form and under its nonce.
| Parameter | Type | Meaning |
|---|---|---|
$post |
WP_Post |
The post being edited |
Data
plugixa_social_share_settings_saved
Fires after the plugin’s settings are written.
| Parameter | Type | Meaning |
|---|---|---|
$settings |
array | The settings as stored |
plugixa_social_share_sets_saved
Fires after a share set is saved, whether new or changed.
| Parameter | Type | Meaning |
|---|---|---|
$saved |
PlugixaSocialShare\Core\Sets\ShareSet |
The set as stored |
add_action( 'plugixa_social_share_sets_saved', function ( $set ) {
error_log( 'Share set ' . $set->id . ' saved: ' . $set->label() );
} );
plugixa_social_share_sets_deleted
Fires after a share set is deleted.
| Parameter | Type | Meaning |
|---|---|---|
$id |
int | The deleted set’s number |
plugixa_social_share_counts_requested
Fires when a page asks the REST API for a published post’s counts. The plugin uses it to register the post for counting, at most once an hour.
| Parameter | Type | Meaning |
|---|---|---|
$post_id |
int | The post |
Filters
Networks, icons and styles
plugixa_social_share_networks
Registers share destinations. Each entry is an array; an entry with no slug
or no label is skipped.
| Key | Type | Meaning |
|---|---|---|
slug |
string | Machine name. Required |
label |
string | The name shown. Required |
group |
string | social, messaging, fediverse, ai, bookmark, regional or utility. Default social |
color |
string | Brand colour as #rrggbb |
icon |
string | Icon id. Defaults to the slug |
url |
string | The share address, with tokens |
app_url |
string | An optional app link, used on touch devices |
supports |
string[] | Any of counts, image, text, via, hashtags, follow |
intent |
string | popup (default), newtab, native, copy, print or mailto |
count_source |
string | The count source that serves this network, if any |
needs_instance |
bool | The visitor is asked for their own server |
instance |
string | The default server for such a network |
order |
int | Position in the picker. Lower is earlier |
The url tokens are {url}, {title}, {text}, {image}, {via} and
{hashtags}. A token with no value is removed along with its empty parameter.
add_filter( 'plugixa_social_share_networks', function ( $networks ) {
$networks[] = array(
'slug' => 'example',
'label' => 'Example',
'group' => 'social',
'color' => '#336699',
'url' => 'https://example.com/share?u={url}&t={title}',
'order' => 95,
);
return $networks;
} );
A network with no icon registered shows its name and colour.
plugixa_social_share_icons
Registers icon artwork.
| Parameter | Type | Meaning |
|---|---|---|
$icons |
array | Icon id => the inner SVG markup of a 24 by 24 symbol, with no wrapping <svg> element |
plugixa_social_share_more_networks
Trims or reorders what a “+” menu offers. A network already in the row is never listed, whatever is returned.
| Parameter | Type | Meaning |
|---|---|---|
$slugs |
string[] | The destinations the menu will list |
$row |
string[] | The destinations already in the row |
plugixa_social_share_templates
Registers button styles. Each entry is an array.
| Key | Type | Meaning |
|---|---|---|
slug |
string | Machine name. Required |
label |
string | The name shown. Required |
group |
string | solid, outline, light, mono, text or special. Default solid |
color_mode |
string | brand (default), mono or custom |
tokens |
array | Values for the style’s tokens |
order |
int | Position in the gallery |
The tokens a style may set are radius, size, gap, pad_x, icon_size,
font_size, font_weight, letter, transform, bg, fg, border,
border_w, hover_bg, hover_fg, hover_border, icon_bg, icon_fg,
shadow, hover_shadow and lift. Anything else is ignored.
plugixa_social_share_follow_services
Adds, removes or changes the services on the Follow buttons screen.
| Parameter | Type | Meaning |
|---|---|---|
$services |
array | Slug => service. Keys per service: slug, label, color, profile, handle, hosts, example, spoken |
plugixa_social_share_count_sources
Filters the count sources that may be called.
| Parameter | Type | Meaning |
|---|---|---|
$sources |
string[] | reddit, tumblr, vk, odnoklassniki, and facebook when a token is saved |
// Never ask VK or Odnoklassniki.
add_filter( 'plugixa_social_share_count_sources', function ( $sources ) {
return array_diff( $sources, array( 'vk', 'odnoklassniki' ) );
} );
Positions and placement
plugixa_social_share_positions
Registers display positions. Each entry is an array; slug and label are
required.
| Key | Type | Meaning |
|---|---|---|
description |
string | Shown as the zone’s tooltip |
group |
string | content, floating, bar, overlay, manual or inline |
exclusive |
bool | Defaults to true for the content group |
hook, priority |
string, int | The WordPress hook it renders on |
css_part |
string | A stylesheet part under assets/frontend/css/parts/ |
needs_script |
bool | Whether the position needs the plugin’s script |
devices |
string | any, mobile or desktop |
types |
string[] | The only placement keys it may be chosen for. Empty for all |
order |
int | Reading order |
plugixa_social_share_footer_positions
Filters the positions drawn at the end of the page, in order. A position that is not active on the page is skipped whatever this returns.
| Parameter | Type | Meaning |
|---|---|---|
$slugs |
string[] | Default: float_left, float_right, bottom_bar, mobile_bar |
plugixa_social_share_placement_markup
Filters the positioning wrapper of a placed set. Return $markup unchanged for
every position you do not own.
| Parameter | Type | Meaning |
|---|---|---|
$markup |
string | The wrapper, with the buttons inside |
$slug |
string | The position |
$html |
string | The buttons alone, already escaped |
plugixa_social_share_placeable_post_types
The post types a share set can be placed on automatically. Starts from every public type minus attachments and known page-builder storage. Only public types count.
| Parameter | Type | Meaning |
|---|---|---|
$slugs |
string[] | The post types offered |
$public |
string[] | Every public post type |
// Do not offer share buttons on the "docs" post type.
add_filter( 'plugixa_social_share_placeable_post_types', function ( $slugs ) {
return array_diff( $slugs, array( 'docs' ) );
} );
plugixa_social_share_is_shareable
Refuses or allows automatic buttons for one request. One post’s own “Show share buttons” switch does not come through here.
| Parameter | Type | Meaning |
|---|---|---|
$shareable |
bool | Whether this request should show automatic buttons |
// No automatic buttons on the checkout page.
add_filter( 'plugixa_social_share_is_shareable', function ( $shareable ) {
return is_page( 'checkout' ) ? false : $shareable;
} );
plugixa_social_share_post_set
The share set that draws one post’s automatic spots, in place of its post type’s. Pro’s per-post set choice answers through this filter. A set that does not exist is ignored.
| Parameter | Type | Meaning |
|---|---|---|
$set |
int | A set’s number; 0 for the post type’s own |
$post_id |
int | The post |
plugixa_social_share_set_usage
Filters what the delete dialog says about a share set’s uses.
| Parameter | Type | Meaning |
|---|---|---|
$usage |
array | Keys posts, total, capped, overrides, overrides_note |
$id |
int | The set |
Deciding what a page loads
These run on wp_enqueue_scripts, before anything is drawn.
plugixa_social_share_active_positions
Which positions will render on this request. An empty array means the page shows no buttons and the plugin enqueues nothing.
| Parameter | Type | Meaning |
|---|---|---|
$active |
string[] | Position slugs |
plugixa_social_share_active_sets
Which share sets will render on this request.
| Parameter | Type | Meaning |
|---|---|---|
$sets |
int[] | Share set numbers |
plugixa_social_share_planned_instance
One planned set’s buttons, as this request will draw them. Must return an
Instance.
| Parameter | Type | Meaning |
|---|---|---|
$instance |
Instance |
The set’s saved look |
$id |
int | The set’s number |
plugixa_social_share_needs_script
Forces the plugin’s script on for the page.
| Parameter | Type | Meaning |
|---|---|---|
$needed |
bool | Whether anything so far needs it |
plugixa_social_share_script_parts
Small extra scripts for pages that show buttons: file names, without the
extension, under assets/frontend/js/parts/. GA4 events use this.
| Parameter | Type | Meaning |
|---|---|---|
$parts |
string[] | Part names |
What is shared
plugixa_social_share_context
Adjusts what is being shared for one post: its title, text, image and so on.
Return a Context.
| Parameter | Type | Meaning |
|---|---|---|
$context |
Context |
The resolved context |
$post |
WP_Post |
The post it came from |
plugixa_social_share_shared_url
Filters the address a network is given to share, per network, before it is encoded into the network’s link. This is where to add query parameters.
| Parameter | Type | Meaning |
|---|---|---|
$url |
string | The page’s address |
$network |
Network |
The destination |
$context |
Context |
What is being shared |
add_filter( 'plugixa_social_share_shared_url', function ( $url, $network, $context ) {
return add_query_arg( 'ref', $network->slug, $url );
}, 10, 3 );
plugixa_social_share_url
Filters a finished share link: the network’s own URL with the address already encoded inside it. Use it to replace a whole link, not to change the shared address.
| Parameter | Type | Meaning |
|---|---|---|
$url |
string | The finished link |
$network |
Network |
The destination |
$context |
Context |
What is being shared |
plugixa_social_share_keep_plain_address PRO
Must this network be given the page’s plain address, unchanged? Pro’s UTM tags and short links ask before changing an address. The free edition answers yes for a network whose share count is being fetched, so its count keeps adding up.
| Parameter | Type | Meaning |
|---|---|---|
$keep |
bool | True to share the plain address |
$network |
Network |
The destination |
// Never tag or shorten links shared to LinkedIn.
add_filter( 'plugixa_social_share_keep_plain_address', function ( $keep, $network ) {
return $keep || 'linkedin' === $network->slug;
}, 10, 2 );
Output
plugixa_social_share_render
Filters a finished row of share buttons.
| Parameter | Type | Meaning |
|---|---|---|
$html |
string | The markup |
$instance |
Instance |
The look it was drawn with |
$context |
Context |
What is being shared |
plugixa_social_share_render_follow
Filters a finished follow row.
| Parameter | Type | Meaning |
|---|---|---|
$html |
string | The markup |
$look |
Instance |
Its look |
$links |
array | The profiles it links to |
plugixa_social_share_link_preview_tags
The link preview tags for the page, before they are printed. Each tag is
array( name, content ). Return an empty array to print none on this page.
| Parameter | Type | Meaning |
|---|---|---|
$tags |
array | The tags |
$subject |
PlugixaSocialShare\Modules\LinkPreviews\Subject |
What the page is |
plugixa_social_share_link_previews_printed_by
Which plugin, or theme, prints each group of link preview tags. Name yours
under og and twitter and this plugin prints neither.
| Parameter | Type | Meaning |
|---|---|---|
$found |
array | Keys og and twitter: a name, or an empty string for none |
$singular |
bool | Whether the page is a single post or page |
add_filter( 'plugixa_social_share_link_previews_printed_by', function ( $found ) {
$found['og'] = 'My Theme';
$found['twitter'] = 'My Theme';
return $found;
} );
Clicks and analytics
plugixa_social_share_click_placements
Placements a click may be recorded under beyond the registered positions.
Pro uses it for image_hover and quote.
| Parameter | Type | Meaning |
|---|---|---|
$placements |
string[] | Slugs, lower case |
plugixa_social_share_analytics_windows
The ranges, in days, the Share analytics screen may ask for. Values outside 1 to 365 are dropped. The admin app must offer the same ranges.
| Parameter | Type | Meaning |
|---|---|---|
$windows |
int[] | Default: 7, 30 |
plugixa_social_share_analytics_payload
Adds a block to what the Share analytics screen is sent, under a key of your own. The plugin’s own keys are restored afterwards and cannot be changed here.
| Parameter | Type | Meaning |
|---|---|---|
$payload |
array | The answer so far |
$days |
int | The range it covers |
Settings
plugixa_social_share_settings_defaults
Adds default values for settings a module owns.
| Parameter | Type | Meaning |
|---|---|---|
$defaults |
array | Key => default value |
plugixa_social_share_sanitize_settings
Lets a module clean the settings it owns when settings are saved. A key that is submitted and not claimed here is dropped.
| Parameter | Type | Meaning |
|---|---|---|
$clean |
array | The plugin’s own keys, already clean |
$input |
array | Everything submitted, merged over what is stored |
add_filter( 'plugixa_social_share_settings_defaults', function ( $defaults ) {
$defaults['my_addon_enabled'] = false;
return $defaults;
} );
add_filter( 'plugixa_social_share_sanitize_settings', function ( $clean, $input ) {
$clean['my_addon_enabled'] = ! empty( $input['my_addon_enabled'] );
return $clean;
}, 10, 2 );
plugixa_social_share_settings_choices
The allowed values of each select field, handed to the admin app.
| Parameter | Type | Meaning |
|---|---|---|
$choices |
array | Keys share_url_source, open_mode, count_format, asset_strategy, each a list of values |
plugixa_social_share_secret_settings
Declares setting keys that hold credentials. A declared key is removed from every settings response; the admin is told only whether it is set.
| Parameter | Type | Meaning |
|---|---|---|
$keys |
string[] | Secret setting keys |
plugixa_social_share_config_settings_keys
Which setting keys are included in the admin app’s start-up data. Do not add a secret here.
| Parameter | Type | Meaning |
|---|---|---|
$keys |
string[] | Setting keys |
Admin app and permissions
plugixa_social_share_admin_config
Filters the start-up data printed for the admin app.
| Parameter | Type | Meaning |
|---|---|---|
$config |
array | The payload |
plugixa_social_share_admin_i18n_strings
Filters the admin app’s string catalogue.
| Parameter | Type | Meaning |
|---|---|---|
$strings |
array | Key => translated text |
plugixa_social_share_user_can
Narrows or widens one authorisation decision. Every REST route that checks a view, create, edit or delete permission asks through it.
| Parameter | Type | Meaning |
|---|---|---|
$allowed |
bool | The answer so far |
$action |
string | read, create, edit, delete or export |
$entity_type |
string | What is acted on, such as sets, settings, analytics, counts |
$record |
array or null | The record, when there is one |
$user_id |
int | The user |
plugixa_social_share_capabilities
Filters the map of what the current user may do, as the admin app reads it. It only decides which buttons are drawn. The server checks every request regardless.
| Parameter | Type | Meaning |
|---|---|---|
$map |
array | Keys manage, view, create, edit, delete, export, manage_settings, each a bool |
plugixa_social_share_filter_output
Filters any payload leaving the plugin’s REST API through its standard success response.
| Parameter | Type | Meaning |
|---|---|---|
$data |
mixed | The payload |
$entity_type |
string | What produced it |
plugixa_social_share_modules
Filters the list of module classes the plugin loads. Lets an add-on contribute a module from outside the plugin’s directory.
| Parameter | Type | Meaning |
|---|---|---|
$classes |
string[] | Fully qualified class names implementing PlugixaSocialShare\Core\Modules\ModuleInterface |
Scheduled events
These are WP-Cron hooks the plugin schedules for itself. They are listed so you can recognise them in a cron inspector.
| Hook | Schedule | What it does |
|---|---|---|
plugixa_social_share_refresh_counts |
Hourly, only while a share set shows counts | Refreshes a batch of share counts |
plugixa_social_share_short_links PRO |
A single event, when links are waiting | Asks the short link service for a batch of links |
Template tags
plugixa_share(), plugixa_get_share(), plugixa_follow() and
plugixa_get_follow() are documented in
Shortcodes.