Filter Hooks

Modify the default behavior of WindPress.

WindPress provides a set of filter hooks that allow you to modify the default behavior of WindPress. These hooks enable you to customize various aspects of the plugin's functionality, such as modifying data before it is saved or displayed.

All filter hooks in WindPress are prefixed with f!windpress/ to ensure compatibility and prevent conflicts with other plugins or themes. This documentation highlights the most commonly used action hooks in WindPress. For a comprehensive list of all available action hooks, use the search functionality in the GitHub repository or code editor to locate all instances of f!windpress/ within the codebase.

f!windpress/integration/loader:register_integrations

This filter hook is triggered when the integration loader registers integrations. It allows you to modify the list of registered integrations before they are used.

  • Location: src/Integration/Loader.php
  • Parameters:
    • IntegrationInterface[] $integrations: The list of registered integrations.
  • Example:
    add_filter('f!windpress/integration/loader:register_integrations', function(array $integrations) {
        // Add a custom integration to the list which will be instantiated and registered with the integration loader.
        $reflectionClass = new ReflectionClass(CustomIntegration::class);
        $instance = $reflectionClass->newInstanceWithoutConstructor();
        $integrations[] = $instance;
    
        return $integrations;
    });
    

f!windpress/core/volume:get_entries.entries

This filter hook is triggered when retrieving entries from a volume. It allows you to modify the list of entries before they are returned.

  • Location: src/Core/Volume.php
  • Parameters:
    • array $entries: The list of entries retrieved from the volume.
  • Example:
    add_filter('f!windpress/core/volume:get_entries.entries', function(array $entries) {
        // add another entry
    
        $entries[] = [
            'name' => 'theme-colors.css',
            'relative_path' => 'theme-colors.css',
            'content' => '/* some css */',
            'handler' => 'my-custom-theme',
            'signature' => 'SECRET-SIGNATURE-HERE',
        ];
    
        return $entries;
    });
    

f!windpress/core/cache:compile.providers

This filter hook is triggered when gathering the list of cache providers. Use this hook to register your own cache provider.

  • Location: src/Core/Cache.php
  • Parameters:
    • array $providers: The list of cache providers. Each provider should have id, name, description, and callback keys.
  • Example:
    add_filter('f!windpress/core/cache:compile.providers', function(array $providers) {
        // Add a custom cache provider
        $providers[] = [
            'id' => 'my-custom-theme',
            'name' => 'My Custom Theme',
            'description' => 'The adapter for my custom theme.',
            'callback' => function() { // This is where you would implement the logic for your custom cache provider.
                $contents = [];
    
                $contents[] = [
                  'name' => 'blog-body.twig',
                  'content' => '<!-- some content -->',
                ];
    
                return $contents;
            },
            'enabled' => true,
        ];
    
        return $providers;
    });
    

f!windpress/core/runtime:is_prevent_load

This filter hook is triggered when checking if the runtime should be prevented from loading on the frontend. Use this hook to conditionally prevent the runtime from loading based on certain criteria.

  • Location: src/Core/Runtime.php
  • Parameters:
    • bool $prevent_load: Whether to prevent the runtime from loading. Default is false.
  • Example:
    add_filter('f!windpress/core/runtime:is_prevent_load', function(bool $prevent_load) {
        // Prevent the runtime from loading on the frontend if a certain condition is met.
        if (!is_admin()) {
            return true;
        }
    
        return $prevent_load;
    });
    

f!windpress/core/runtime:tailwindcss_version

This filter hook is triggered when retrieving the Tailwind CSS version. Use this hook to modify the version of Tailwind CSS used in WindPress.

  • Location: src/Core/Runtime.php
  • Parameters:
    • int $version: The version of Tailwind CSS. Default is 4.
  • Example:
    add_filter('f!windpress/core/runtime:tailwindcss_version', function(int $version) {
        // Change the Tailwind CSS version to a custom version.
        return 3;
    });
    

f!windpress/core/runtime:append_header.cache_enabled

This filter hook is triggered when checking if the header of frontend should load the cache instead of the Compiler.

  • Location: src/Core/Runtime.php
  • Parameters:
    • bool $cache_enabled: Whether caching is enabled for the header. Default is false and the Compiler will be used.
  • Example:
    add_filter('f!windpress/core/runtime:append_header.cache_enabled', function(bool $cache_enabled) {
        // Enable caching for the header on the frontend.
        return true;
    });
    

f!windpress/core/runtime:append_header.exclude_admin

This filter hook is triggered when checking if the user with administrator role should be excluded from loading the cache on the frontend.

  • Location: src/Core/Runtime.php
  • Parameters:
    • bool $exclude_admin: Whether to exclude the user with administrator role from loading the cache. Default is false and the administrator will always load the Compiler.
  • Example:
    add_filter('f!windpress/core/runtime:append_header.exclude_admin', function(bool $exclude_admin) {
        // Exclude the user with `administrator` role from loading the cache on the frontend.
        return true;
    });