automattic / jetpack-sharing-likes
Sharing buttons and Like buttons for your posts.
Package info
github.com/Automattic/jetpack-sharing-likes
Type:jetpack-library
pkg:composer/automattic/jetpack-sharing-likes
Requires
- php: >=7.4
- automattic/jetpack-assets: ^5.0.16
- automattic/jetpack-connection: ^9.15.0
- automattic/jetpack-status: ^7.1.1
- automattic/jetpack-wp-build-polyfills: ^0.7.1
Requires (Dev)
- automattic/phpunit-select-config: ^1.0.12
- yoast/phpunit-polyfills: ^4.0.0
Suggests
- automattic/jetpack-autoloader: Allow for better interoperability with other plugins that use this package.
Provides
None
Conflicts
None
Replaces
None
This package is auto-updated.
Last update: 2026-10-30 19:47:53 UTC
README
Sharing buttons and Like buttons for your posts.
Today the package ships the wp-admin Settings > Sharing screen, under
src/settings/, and the same settings over REST, under wpcom/v2/sharing-likes/,
for the React version of the screen. A host plugin sets both up with one call,
on every request rather than in an is_admin() branch, since REST requests are
not admin requests, and Calypso's sidebar is built in one:
\Automattic\Jetpack\Sharing_Likes\Initializer::init();
Neither depends on a module being active: the screen and every section on it exist whichever modules are on, on any site that is Simple, connected, or in offline mode.
The same call hooks the Sharing Buttons and Like blocks into block themes' single
post and page templates, before or after the post content, wherever the
jetpack_sharing_buttons_auto_add and jetpack_likes_auto_add options ask for
them and the legacy buttons are off. The settings REST route reads and saves them
as sharing_buttons_auto_add and likes_auto_add; to try it without a screen:
wp option update jetpack_sharing_buttons_auto_add '["after_content"]' --format=json
wp option update jetpack_likes_auto_add '["before_content"]' --format=json
Single posts and pages get them by default. To add another post type's single views:
add_filter( 'jetpack_sharing_likes_template_placement_post_types', function ( $post_types ) { $post_types[] = 'product'; return $post_types; } );
It also ships the per-post Likes and Sharing switches the block editor shows, as
REST fields on every public post type. Initializer::init() leaves these out:
each belongs to the feature that reads it, so call it wherever that feature
loads (Likes or Comment Likes, and Sharing), outside any is_admin() branch:
\Automattic\Jetpack\Sharing_Likes\Post_Likes_Switch::init(); \Automattic\Jetpack\Sharing_Likes\Post_Sharing_Switch::init();
Calling either more than once is harmless.
React screen
Settings > Sharing renders a React version by default. To get the PHP screen back until it retires:
add_filter( 'rsm_jetpack_ui_modernization_sharing_likes', '__return_false' );
Add it before admin_menu runs, for example from a plugin or mu-plugin: the filter is
read on admin_menu at priority 1, so adding it on admin_init silently does nothing.
Build it with pnpm run build (or jp build packages/sharing-likes).
How to install sharing-likes
Installation From Git Repo
Contribute
Get Help
Using this package in your WordPress plugin
If you plan on using this package in your WordPress plugin, we would recommend that you use Jetpack Autoloader as your autoloader. This will allow for maximum interoperability with other plugins that use this package as well.
Security
Need to report a security vulnerability? Go to https://automattic.com/security/ or directly to our security bug bounty site https://hackerone.com/automattic.
License
sharing-likes is licensed under GNU General Public License v2 (or later)