Overview
LionWP plugins are built with extensibility in mind. All our plugins provide numerous action and filter hooks that allow developers to customize and extend functionality without modifying core plugin files.
Lion Social Share v1.0.4
Social sharing with 35+ platforms and extensive customization hooks
Lion GDPR Coming Soon
GDPR compliance with consent management and privacy tools
Lion Under Construction Coming Soon
Maintenance pages with email collection and launch notifications
Hook Naming Patterns
All LionWP plugins follow consistent naming patterns that make it easy to predict and use hooks across our entire plugin ecosystem.
Standard Patterns
// Action Hook Pattern
lionwp_{plugin_name}_{timing}_{component}
// Filter Hook Pattern
lionwp_{plugin_name}_{data_type}
// Examples:
lionwp_social_share_before_buttons // Action
lionwp_social_share_after_buttons // Action
lionwp_social_share_platforms // Filter
lionwp_social_share_settings // Filter
lionwp_gdpr_before_notice // Action (coming soon)
lionwp_gdpr_consent_options // Filter (coming soon)
lionwp_construction_before_page // Action (coming soon)
lionwp_construction_email_settings // Filter (coming soon)
Action Hooks
Action hooks allow you to execute custom code at specific points in plugin execution. All LionWP plugins provide "before" and "after" actions for their main functions.
| Parameter | Type | Description |
|---|---|---|
| $context_id | int | ID of current context (post ID, page ID, etc.) |
| $settings | array | Plugin settings and configuration |
| $instance_data | array | Instance-specific data (widget, shortcode, etc.) |
// Social Share: Add content before buttons
function my_before_social_buttons($post_id, $settings, $instance) {
echo '<div class="custom-intro">Share this content:</div>';
}
add_action('lionwp_social_share_before_buttons', 'my_before_social_buttons', 10, 3);
// GDPR: Add content before consent notice (coming soon)
function my_before_gdpr_notice($context_id, $settings, $instance) {
echo '<div class="privacy-intro">Your privacy matters to us</div>';
}
add_action('lionwp_gdpr_before_notice', 'my_before_gdpr_notice', 10, 3);
// Under Construction: Add content before maintenance page (coming soon)
function my_before_construction_page($page_id, $settings, $instance) {
if ($settings['show_logo']) {
echo '<div class="custom-logo">' . get_custom_logo() . '</div>';
}
}
add_action('lionwp_construction_before_page', 'my_before_construction_page', 10, 3);
// Social Share: Track button displays
function track_social_display($post_id, $platform_count, $instance) {
// Send to analytics
wp_remote_post('https://analytics.example.com/track', array(
'body' => array(
'event' => 'social_buttons_displayed',
'post_id' => $post_id,
'platforms' => $platform_count
)
));
}
add_action('lionwp_social_share_after_buttons', 'track_social_display', 10, 3);
// GDPR: Log consent notice display (coming soon)
function log_gdpr_notice_shown($context_id, $notice_type, $instance) {
error_log("GDPR notice shown: {$notice_type} on context {$context_id}");
}
add_action('lionwp_gdpr_after_notice', 'log_gdpr_notice_shown', 10, 3);
// Under Construction: Track page views (coming soon)
function track_construction_view($page_id, $visitor_data, $instance) {
$views = get_option('construction_page_views', 0);
update_option('construction_page_views', $views + 1);
}
add_action('lionwp_construction_after_page', 'track_construction_view', 10, 3);
// Universal interaction tracker for all LionWP plugins
function track_lionwp_interactions($interaction_type, $context_id, $data, $user_id = 0) {
$user_id = $user_id ?: get_current_user_id();
// Log to database
global $wpdb;
$wpdb->insert(
$wpdb->prefix . 'lionwp_interactions',
array(
'plugin' => $data['plugin'] ?? 'unknown',
'interaction' => $interaction_type,
'context_id' => $context_id,
'user_id' => $user_id,
'data' => json_encode($data),
'timestamp' => current_time('mysql')
)
);
}
// Apply to all current and future LionWP plugins
add_action('lionwp_social_share_button_clicked', 'track_lionwp_interactions', 10, 4);
add_action('lionwp_gdpr_consent_given', 'track_lionwp_interactions', 10, 4);
add_action('lionwp_gdpr_consent_withdrawn', 'track_lionwp_interactions', 10, 4);
add_action('lionwp_construction_email_submitted', 'track_lionwp_interactions', 10, 4);
Filter Hooks
Filter hooks allow you to modify data before it's processed or displayed. All LionWP plugins provide filters for settings, content, and data arrays.
// Universal settings modifier for all LionWP plugins
function customize_lionwp_settings($settings, $context, $plugin_name = '') {
// Add universal branding
$settings['show_lionwp_credit'] = get_option('lionwp_show_credits', false);
// Add universal analytics
$settings['track_interactions'] = get_option('lionwp_analytics_enabled', true);
// Context-specific modifications
switch ($context) {
case 'widget':
$settings['lazy_load'] = true;
break;
case 'shortcode':
$settings['cache_enabled'] = true;
break;
case 'auto':
$settings['respect_user_preferences'] = true;
break;
}
// Plugin-specific customizations
if ($plugin_name === 'social_share') {
// Different platforms for different post types
if (is_singular('product')) {
$settings['platforms'] = array('facebook', 'pinterest', 'email');
}
}
return $settings;
}
// Apply to all LionWP plugins
add_filter('lionwp_social_share_settings', 'customize_lionwp_settings', 10, 3);
add_filter('lionwp_gdpr_settings', 'customize_lionwp_settings', 10, 3);
add_filter('lionwp_construction_settings', 'customize_lionwp_settings', 10, 3);
// Universal HTML enhancer for all LionWP plugins
function enhance_lionwp_html($html, $context, $data = array()) {
// Add universal accessibility attributes
$html = str_replace('<a ', '<a role="button" ', $html);
$html = str_replace('<button ', '<button type="button" ', $html);
// Add schema markup
if (strpos($html, 'social-share') !== false) {
$html = str_replace(
'<div class="lionwp-social',
'<div itemscope itemtype="http://schema.org/ShareAction" class="lionwp-social',
$html
);
}
// Add tracking attributes
if (isset($data['track']) && $data['track']) {
$html = str_replace('<a ', '<a data-track="lionwp-interaction" ', $html);
}
// Add custom CSS classes
$custom_class = get_option('lionwp_custom_css_class', '');
if ($custom_class) {
$html = str_replace('class="', 'class="' . esc_attr($custom_class) . ' ', $html);
}
return $html;
}
// Apply to all LionWP plugin HTML outputs
add_filter('lionwp_social_share_button_html', 'enhance_lionwp_html', 10, 3);
add_filter('lionwp_gdpr_notice_html', 'enhance_lionwp_html', 10, 3);
add_filter('lionwp_construction_page_html', 'enhance_lionwp_html', 10, 3);
// Add custom platforms to Social Share
function add_business_platforms($platforms, $context_id) {
// Add Slack for team sharing
$platforms['slack'] = array(
'name' => 'Slack',
'icon' => 'fab fa-slack',
'url' => 'https://slack.com/share?url={url}&title={title}',
'color' => '#4A154B',
'category' => 'business'
);
// Add Microsoft Teams
$platforms['teams'] = array(
'name' => 'Microsoft Teams',
'icon' => 'fab fa-microsoft',
'url' => 'https://teams.microsoft.com/share?href={url}&title={title}',
'color' => '#6264A7',
'category' => 'business'
);
return $platforms;
}
add_filter('lionwp_social_share_platforms_data', 'add_business_platforms', 10, 2);
// Add custom GDPR consent options (coming soon)
function add_custom_consent_options($options, $context_id) {
$options['marketing_analytics'] = array(
'label' => 'Marketing Analytics',
'description' => 'Help us improve our marketing with anonymous usage data',
'required' => false,
'default' => false,
'category' => 'marketing'
);
$options['personalization'] = array(
'label' => 'Content Personalization',
'description' => 'Customize content based on your preferences',
'required' => false,
'default' => true,
'category' => 'functional'
);
return $options;
}
add_filter('lionwp_gdpr_consent_options_data', 'add_custom_consent_options', 10, 2);
// Add custom construction page templates (coming soon)
function add_construction_templates($templates, $context_id) {
$templates['corporate'] = array(
'name' => 'Corporate',
'description' => 'Professional business template',
'preview' => 'corporate-preview.jpg',
'features' => array('countdown', 'email_signup', 'social_links')
);
return $templates;
}
add_filter('lionwp_construction_templates_data', 'add_construction_templates', 10, 2);
Best Practices
Safety & Security
// Always check if plugins are active before using hooks
function safe_lionwp_customization() {
// Check for specific plugin classes
$active_plugins = array();
if (class_exists('LionWP_Social_Share')) {
$active_plugins[] = 'social_share';
}
if (class_exists('LionWP_GDPR')) {
$active_plugins[] = 'gdpr';
}
if (class_exists('LionWP_Construction')) {
$active_plugins[] = 'construction';
}
// Only add hooks for active plugins
foreach ($active_plugins as $plugin) {
add_action("lionwp_{$plugin}_before_buttons", 'my_custom_function', 10, 3);
}
}
add_action('plugins_loaded', 'safe_lionwp_customization');
// Secure data handling
function secure_lionwp_handler($user_input, $context_id, $settings) {
// Validate all inputs
if (!is_numeric($context_id) || $context_id < 1) {
return false;
}
// Sanitize user data
$user_input = sanitize_text_field($user_input);
// Check permissions
if (!current_user_can('read')) {
return false;
}
// Verify nonces for forms
if (isset($_POST['lionwp_nonce'])) {
if (!wp_verify_nonce($_POST['lionwp_nonce'], 'lionwp_action')) {
wp_die('Security check failed');
}
}
return true;
}
Performance Optimization
// Conditional loading - only load where needed
function conditional_lionwp_hooks() {
// Only on single posts and pages
if (is_singular()) {
add_action('lionwp_social_share_before_buttons', 'my_social_function', 10, 3);
}
// Only for logged-in users
if (is_user_logged_in()) {
add_filter('lionwp_gdpr_settings', 'modify_gdpr_for_users', 10, 3);
}
// Only on specific post types
if (is_singular('product')) {
add_filter('lionwp_social_share_platforms_data', 'add_ecommerce_platforms', 10, 2);
}
}
add_action('template_redirect', 'conditional_lionwp_hooks');
// Cache expensive operations
function cached_lionwp_data($context_id) {
$cache_key = "lionwp_data_{$context_id}";
$cached_data = wp_cache_get($cache_key, 'lionwp');
if (false === $cached_data) {
// Expensive operation here
$cached_data = expensive_data_operation($context_id);
// Cache for 1 hour
wp_cache_set($cache_key, $cached_data, 'lionwp', 3600);
}
return $cached_data;
}
// Minimize database queries
function optimized_lionwp_tracking($interactions) {
// Batch multiple interactions
static $batch = array();
$batch[] = $interactions;
// Process in batches of 10
if (count($batch) >= 10) {
global $wpdb;
$values = array();
foreach ($batch as $interaction) {
$values[] = $wpdb->prepare(
"(%s, %d, %s, %s)",
$interaction['type'],
$interaction['context_id'],
$interaction['data'],
current_time('mysql')
);
}
$wpdb->query(
"INSERT INTO {$wpdb->prefix}lionwp_interactions
(type, context_id, data, timestamp) VALUES " . implode(',', $values)
);
$batch = array(); // Clear batch
}
}
Future Compatibility
// Auto-detect new LionWP plugins
function auto_hook_lionwp_plugins() {
$plugin_classes = array(
'LionWP_Social_Share' => 'social_share',
'LionWP_GDPR' => 'gdpr',
'LionWP_Construction' => 'construction',
'LionWP_SEO' => 'seo', // Future plugin
'LionWP_Security' => 'security', // Future plugin
'LionWP_Analytics' => 'analytics' // Future plugin
);
foreach ($plugin_classes as $class => $plugin_key) {
if (class_exists($class)) {
// Auto-hook common patterns
add_action("lionwp_{$plugin_key}_before_buttons", 'universal_before_handler', 10, 3);
add_action("lionwp_{$plugin_key}_after_buttons", 'universal_after_handler', 10, 3);
add_filter("lionwp_{$plugin_key}_settings", 'universal_settings_filter', 10, 3);
}
}
}
add_action('plugins_loaded', 'auto_hook_lionwp_plugins');
// Universal function naming
function mytheme_lionwp_customization($data, $context, $plugin = '') {
// This function works with all current and future LionWP plugins
// because it follows the universal parameter pattern
return $data;
}
// Hook priority system for compatibility
define('LIONWP_PRIORITY_CRITICAL', 5); // Must run first
define('LIONWP_PRIORITY_NORMAL', 10); // Standard priority
define('LIONWP_PRIORITY_LATE', 20); // After other customizations
define('LIONWP_PRIORITY_CLEANUP', 50); // Final processing
// Use consistent priorities across all hooks
add_action('lionwp_social_share_before_buttons', 'my_function', LIONWP_PRIORITY_NORMAL, 3);
add_action('lionwp_gdpr_before_notice', 'my_function', LIONWP_PRIORITY_NORMAL, 3);
add_action('lionwp_construction_before_page', 'my_function', LIONWP_PRIORITY_NORMAL, 3);
Limited-Time Offer
Plugin-Specific Examples
Social Share Plugin
Universal Plugin Handler