Hooks & Filters

Hooks & Filters Reference

MagicBlog provides extensive hooks and filters for developers to customize functionality, extend features, and integrate with other plugins. This comprehensive reference covers all available customization points.

🎯 Action Hooks

Plugin Lifecycle Hooks

magicblog_plugin_loaded

Fires when MagicBlog is fully loaded and initialized.

add_action('magicblog_plugin_loaded', 'my_magicblog_init');
function my_magicblog_init() {
    // Plugin is ready for customization
    error_log('MagicBlog is now loaded');
}

magicblog_before_activation

Fires before plugin activation process begins.

add_action('magicblog_before_activation', 'my_pre_activation_tasks');
function my_pre_activation_tasks() {
    // Perform checks before activation
    if (!current_user_can('manage_options')) {
        wp_die('Insufficient permissions');
    }
}

magicblog_after_activation

Fires after successful plugin activation.

magicblog_before_deactivation

Fires before plugin deactivation.


Database Hooks

magicblog_before_track_engagement

Fires before engagement data is saved to database.

magicblog_after_track_engagement

Fires after engagement data is successfully saved.

magicblog_stats_updated

Fires when post statistics are recalculated.


Block & Widget Hooks

magicblog_before_render_block

Fires before any MagicBlog block is rendered.

magicblog_after_render_block

Fires after block rendering is complete.

magicblog_widget_before_render

Fires before Elementor widgets are rendered.


Admin Interface Hooks

magicblog_admin_dashboard_before

Fires before admin dashboard content is rendered.

magicblog_admin_dashboard_after

Fires after admin dashboard content.

magicblog_settings_page_loaded

Fires when settings page is loaded.


🔍 Filter Hooks

Data Modification Filters

magicblog_engagement_value

Filters engagement value before saving.

magicblog_user_can_engage

Filters whether user can engage with content.

magicblog_rate_limit_time

Filters rate limiting duration.


Query Modification Filters

magicblog_posts_query_args

Filters query arguments for post fetching.

magicblog_stats_query

Filters statistics database query.


Display Filters

magicblog_format_number

Filters number formatting for display.

magicblog_star_rating_html

Filters star rating HTML output.

magicblog_engagement_buttons_html

Filters engagement buttons HTML.


Block & Widget Filters

magicblog_block_attributes

Filters block attributes before rendering.

magicblog_widget_settings

Filters Elementor widget settings.


Performance & Caching Filters

magicblog_cache_duration

Filters cache duration for different data types.

magicblog_should_cache

Filters whether specific data should be cached.


🔧 Custom Integration Examples

Custom Engagement Type

Add a new "bookmark" engagement type:

Custom Analytics Dashboard Widget

Add a custom widget to the admin dashboard:

Last updated