AddToSome Share Buttons
A performant, modular WordPress plugin that adds customizable share buttons to your posts and pages.
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/xwp/add-to-some/archive/refs/heads/main.zipReadme
AddToSome Share Buttons
A performant, modular WordPress plugin that adds customizable share buttons to your posts and pages. Built with clean, maintainable code.
Features
-
Multiple Sharing Services
- Pinterest sharing with image support
- Facebook sharing (with optional App ID for enhanced dialog)
- X (formerly Twitter) sharing (with optional handle)
- Pocket save functionality
- LinkedIn share
- Reddit share
- Email sharing with pre-filled content
- Native browser sharing (Web Share API)
-
Customization Options
- Adjustable icon size (10-300 pixels)
- Flexible placement (as a Gutenberg block, before or after the post content, or in both places)
- Per-service enable/disable toggles
- Reorder enabled buttons via drag-and-drop in the admin
- Platform-specific configuration
- Multiple block instances supported for different content sections
-
Performance Optimized
- Lazy loading of assets
- Minimal JavaScript footprint
- Clean, semantic HTML output
- No external dependencies
Installation
- Upload the
add-to-somefolder to/wp-content/plugins/ - Activate the plugin through the 'Plugins' menu in WordPress
- Configure settings under Settings > AddToSome
Composer Installation
To install the plugin via Composer, follow these steps:
-
Add the Repository:
-
Open your project's
composer.jsonfile. -
Add the following under the
repositoriessection:"repositories": [ { "type": "vcs", "url": "https://github.com/xwp/add-to-some" } ]
-
-
Require the Plugin:
-
Run the following command in your terminal:
composer require xwp/add-to-some
-
-
Activate the Plugin:
- Once installed, activate the plugin through the 'Plugins' menu in WordPress.
Configuration
Basic Settings
- Icon Style: Set the size of share button icons (10-300 pixels)
- Share Buttons: Enable/disable individual sharing services
- Placement on single posts: Choose where buttons appear automatically:
top- Above post contentbottom- Below post content (default)both- Above and below post contentnone (manual placement)- No automatic placement; use the Add to Some - Share Buttons block in the editor
Using the Share Buttons Block
The plugin includes a Gutenberg block for manual placement:
- In the post/page editor, click the + button to add a block
- Search for "Share Buttons"
- Insert the block wherever you want share buttons to appear
- The block shows a preview of your configured buttons in the editor
- Configure button settings via Settings > AddToSome (link available in block sidebar)
- You can add multiple Share Buttons blocks in different locations
Note: When using the block, set Placement to "none (manual placement)" to prevent automatic insertion at top/bottom.
Advanced Options
Facebook App ID
For enhanced Facebook sharing features:
- Visit developers.facebook.com
- Create a new app (Consumer type)
- Copy the App ID from your app dashboard
- Paste it in the plugin settings
Without an App ID, the plugin uses Facebook's basic sharer functionality.
X (Twitter) Handle
Add your X handle to include "via @yourhandle" in shared tweets.
Architecture
The plugin follows a modern, object-oriented architecture with clear separation of concerns:
File Structure
add-to-some/
├── add-to-some.php # Main plugin file and bootstrapper
├── includes/
│ ├── autoloader.php # PSR-4 style autoloader
│ ├── compat.php # Backward compatibility functions
│ └── classes/
│ ├── class-plugin.php # Main plugin controller
│ ├── class-settings.php # Settings management
│ ├── class-admin.php # Admin interface
│ ├── class-frontend.php # Frontend functionality
│ ├── class-share-buttons.php # Share link generation
│ └── class-renderer.php # HTML rendering
├── js/
│ ├── admin.js # Admin UI enhancements
│ └── frontend.js # Native share functionality
└── README.md
Class Overview
- Plugin: Main controller, singleton pattern, coordinates all components
- Settings: Manages options, validation, and sanitization
- Admin: Handles admin interface, settings page, and field rendering
- Frontend: Content filtering and asset enqueueing
- ShareButtons: Generates platform-specific share URLs
- Renderer: Builds HTML output with proper escaping
Coding Standards
The plugin adheres to:
- WordPress VIP coding standards
- PSR-4 autoloading conventions
- WordPress security best practices
- Proper data validation and sanitization
- Contextual escaping for all output
Hooks and Filters
Actions
plugins_loaded- Plugin initializationadmin_menu- Settings page registrationadmin_enqueue_scripts- Admin assetswp_enqueue_scripts- Frontend assetsinit- Text domain loading
Filters
the_content- Button injection (priority 98)plugin_action_links_*- Settings link in plugins listxwp_add_to_some_display_buttons- Control button visibility
Developer API
Getting Plugin Options
// Using the Settings class (recommended)
$settings = \XWP\AddToSome\Settings::get_instance();
$options = $settings->get_options();
// Using compatibility function
$options = xwp_add_to_some_get_options();
Customizing Button Display
// Prevent buttons on specific pages
add_filter( 'xwp_add_to_some_display_buttons', function( $display ) {
if ( is_page( 'special-page' ) ) {
return false;
}
return $display;
} );
Rendering Buttons Programmatically
// Get the plugin instance
$plugin = \XWP\AddToSome\Plugin::get_instance();
$settings = $plugin->get_settings();
$options = $settings->get_options();
// Create renderer and output buttons
$renderer = new \XWP\AddToSome\Renderer( $options, $post_id );
echo $renderer->render();
Requirements
- WordPress 6.0 or higher
- PHP 7.4 or higher
- JavaScript enabled for native sharing
Security
- All user inputs are sanitized
- All outputs are properly escaped
- Nonces used for form submissions
- Capability checks for admin functions
- No direct file access allowed
Performance
- Minimal database queries (single option)
- Assets loaded only when needed
- No render-blocking resources
- Efficient DOM manipulation
License
GPLv2 or later
Support
For issues, feature requests, or contributions, please use the plugin's support forum or repository.
Changelog
1.0.3
- Replace ul/li by div for the template.
- Improve code security, implemented defensive coding techniques.
1.0.2
- Open sharer as centred popup on desktop browsers (>1024 in width)
1.0.1
- Added drag-and-drop reordering of enabled share buttons in the admin
- Renderer output now respects the saved order
- Bumped plugin and asset versions for cache-busting
1.0.0
- Complete refactor with modular architecture
- Improved code organization and readability
- Enhanced security and performance
Read the full README on GitHub →
Releases
These releases are tags only. The author does not attach a packaged zip, so there are no download counts to report.