A performant, modular WordPress plugin that adds customizable share buttons to your posts and pages. Built with clean, maintainable code.
-
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 (top, bottom, or both)
- Per-service enable/disable toggles
- Reorder enabled buttons via drag-and-drop in the admin
- Platform-specific configuration
-
Performance Optimized
- Lazy loading of assets
- Minimal JavaScript footprint
- Clean, semantic HTML output
- No external dependencies
- Upload the
add-to-some
folder to/wp-content/plugins/
- Activate the plugin through the 'Plugins' menu in WordPress
- Configure settings under Settings > AddToSome
- Icon Style: Set the size of share button icons (10-300 pixels)
- Share Buttons: Enable/disable individual sharing services
- Placement: Choose where buttons appear on single posts
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.
Add your X handle to include "via @yourhandle" in shared tweets.
The plugin follows a modern, object-oriented architecture with clear separation of concerns:
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
- 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
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
plugins_loaded
- Plugin initializationadmin_menu
- Settings page registrationadmin_enqueue_scripts
- Admin assetswp_enqueue_scripts
- Frontend assetsinit
- Text domain loading
the_content
- Button injection (priority 98)plugin_action_links_*
- Settings link in plugins listxwp_add_to_some_display_buttons
- Control button visibility
// 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();
// Prevent buttons on specific pages
add_filter( 'xwp_add_to_some_display_buttons', function( $display ) {
if ( is_page( 'special-page' ) ) {
return false;
}
return $display;
} );
// 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();
- WordPress 6.0 or higher
- PHP 7.4 or higher
- JavaScript enabled for native sharing
- 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
- Minimal database queries (single option)
- Assets loaded only when needed
- No render-blocking resources
- Efficient DOM manipulation
GPLv2 or later
For issues, feature requests, or contributions, please use the plugin's support forum or repository.
- Replace ul/li by div for the template.
- Improve code security, implemented defensive coding techniques.
- Open sharer as centred popup on desktop browsers (>1024 in width)
- 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
- Complete refactor with modular architecture
- Improved code organization and readability
- Enhanced security and performance