Skip to main content

Hooks and Filters Overview

The LLMTAG plugin provides a comprehensive set of WordPress hooks and filters that allow developers to extend and customize the plugin’s functionality.

Developer Extensibility

Action HooksFilter HooksCustom FunctionsPlugin Integration

Action Hooks

Core Plugin Actions

llmtag_init

Fired when the plugin is initialized.

llmtag_settings_saved

Fired when plugin settings are saved.

llmtag_agent_blocked

Fired when an AI agent is blocked.

llmtag_llmtag_txt_generated

Fired when the llmtag.txt file is generated.

Analytics Actions

llmtag_analytics_updated

Fired when analytics data is updated.

llmtag_daily_report_generated

Fired when daily analytics report is generated.

Filter Hooks

Content Generation Filters

llmtag_txt_content

Filter the content of the generated llmtag.txt file.

llmtag_global_policies

Filter global AI policies before they are applied.

llmtag_path_policies

Filter path-specific policies.

Agent Blocking Filters

llmtag_blocked_agents

Filter the list of blocked AI agents.

llmtag_agent_blocking_decision

Filter the decision to block or allow an AI agent.

llmtag_user_agent_detection

Filter user agent detection logic.

Analytics Filters

llmtag_analytics_data

Filter analytics data before it’s stored.

llmtag_analytics_query

Filter analytics database queries.

Custom Functions

Utility Functions

llmtag_is_ai_agent()

Check if a user agent is an AI agent.

llmtag_get_policies()

Get current LLMTAG policies.

llmtag_log_activity()

Log custom activity to LLMTAG analytics.

Integration Examples

Custom Post Type Integration

WooCommerce Integration

Membership Plugin Integration

Advanced Customization

Custom Admin Pages

Custom API Endpoints

Custom Database Tables

Best Practices

Hook Usage

Use Appropriate Hooks

Choose the right hook for your use case to avoid conflicts.

Set Proper Priorities

Use appropriate priority values to control execution order.

Clean Up Hooks

Remove hooks when plugins are deactivated to prevent conflicts.

Document Customizations

Document all custom hooks and filters for future reference.

Performance Considerations

Follow these tips to optimize hook performance:
  • Minimize hook usage to reduce overhead
  • Use efficient callbacks to avoid performance bottlenecks
  • Cache expensive operations in hook callbacks
  • Monitor hook performance and optimize as needed

Security Best Practices

Always follow security best practices when using hooks:
  • Validate all inputs in hook callbacks
  • Sanitize data before processing
  • Use proper capabilities for permission checks
  • Escape output to prevent XSS attacks

Troubleshooting

Common Issues

Possible causes:
  • Hook not properly registered
  • Priority conflicts
  • Plugin conflicts
Solutions:
  • Check hook registration
  • Adjust hook priorities
  • Test with other plugins deactivated
Possible causes:
  • Hook callback errors
  • Filter return value issues
  • Logic errors in callbacks
Solutions:
  • Debug hook callbacks
  • Check return values
  • Review callback logic
Possible causes:
  • Too many hooks
  • Inefficient callbacks
  • Heavy operations in hooks
Solutions:
  • Optimize hook usage
  • Improve callback efficiency
  • Move heavy operations to background