Action Hooks

Run custom functions at specific points in the execution of WindPress.

WindPress provides a set of action hooks to run custom functions at a specific point in the execution of WindPress, enabling powerful extensions and customizations.

All action hooks in WindPress are prefixed with a!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 a!windpress/ within the codebase.

a!windpress/integration/loader:scan_integrations.before_scan

This action hook is triggered before the integration scanner starts scanning for integrations. It uses the Symfony Finder component to scan for integrations in the specified directories. It allows you to modify the Finder instance before the scan begins.

  • Location: src/Integration/Loader.php
  • Parameters:
    • Finder $finder: The Symfony Finder instance used to scan for integrations.
  • Example:
    add_action('a!windpress/integration/loader:scan_integrations.before_scan', function($finder) {
        // Add custom directories to the finder instance
        $finder->in('/path/to/custom/directory');
    });
    

a!windpress/core/cache:save_cache.after

This action hook is triggered after the cache is saved. It allows you to perform additional actions after the cache has been successfully saved.

  • Location: src/Core/Cache.php
  • Parameters:
    • string $payload: The payload that was saved to the cache.
  • Example:
    add_action('a!windpress/core/cache:save_cache.after', function(string $payload) {
        // Save a copy of the payload to a custom location
        file_put_contents('/path/to/custom/location/cache_payload.txt', $payload);
    });
    

a!windpress/core/runtime:enqueue_css_cache.before

This action hook is triggered before the CSS cache is enqueued on the frontend. It allows you to enqueue additional CSS files or styles before the WindPress CSS cache is loaded.

  • Location: src/Core/Runtime.php
  • Parameters: None
  • Example:
    add_action('a!windpress/core/runtime:enqueue_css_cache.before', function() {
        // Enqueue a custom CSS file
        wp_enqueue_style('custom-style', get_template_directory_uri() . '/css/custom-style.css');
    });
    

a!windpress/core/runtime:enqueue_css_cache.after

This action hook is triggered after the CSS cache is enqueued on the frontend. It allows you to perform additional actions after the WindPress CSS cache has been successfully loaded.

  • Location: src/Core/Runtime.php
  • Parameters:
    • string $handle: The handle of the enqueued CSS cache.
  • Example:
    add_action('a!windpress/core/runtime:enqueue_css_cache.after', function(string $handle) {
        // Log the handle of the enqueued CSS cache
        error_log('Enqueued CSS cache handle: ' . $handle);
    });
    

a!windpress/core/runtime:enqueue_play_cdn.before

This action hook is triggered before the Play CDN is enqueued on the frontend. It allows you to perform additional actions before the Play CDN is loaded.

  • Location: src/Core/Runtime.php
  • Parameters: None
  • Example:
    add_action('a!windpress/core/runtime:enqueue_play_cdn.before', function() {
        // Perform actions before the Play CDN is loaded
        error_log('Preparing to load Play CDN...');
    });
    

a!windpress/core/runtime:enqueue_play_cdn.after

This action hook is triggered after the Play CDN is enqueued on the frontend. It allows you to perform additional actions after the Play CDN has been successfully loaded.

  • Location: src/Core/Runtime.php
  • Parameters:
    • int $tailwindcss_version: The version of Tailwind CSS used in the Play CDN.
  • Example:
    add_action('a!windpress/core/runtime:enqueue_play_cdn.after', function(int $tailwindcss_version) {
        // Log the version of Tailwind CSS used in the Play CDN
        error_log('Loaded Play CDN with Tailwind CSS version: ' . $tailwindcss_version);
    });
    

a!windpress/core/volume:get_entries.finder

This action hook is triggered when the volume entries are being retrieved. It allows you to modify the Finder instance used to retrieve the entries.

  • Location: src/Core/Volume.php
  • Parameters:
    • Finder $finder: The Symfony Finder instance used to retrieve the volume entries.
  • Example:
    add_action('a!windpress/core/volume:get_entries.finder', function(Finder $finder) {
        // Add custom directories to the finder instance
        $finder->in('/path/to/custom/directory');
    });
    

a!windpress/core/volume:save_entries.entry

This action hook is triggered when a volume entry is being saved. It allows you to perform additional actions after the entry has been successfully saved.

  • Location: src/Core/Volume.php
  • Parameters:
    • mixed $entry: The entry that was saved.
  • Example:
    add_action('a!windpress/core/volume:save_entries.entry', function($entry) {
        // Check if the entry's handler is 'my-custom-theme' and relative-path is 'theme.css'
        if ($entry['handler'] === 'my-custom-theme' && $entry['relative_path'] === 'theme.css') {
            // Perform save action
            file_put_contents('/path/to/custom/location/theme.css', $entry['content']);
        }
    });
    

a!windpress/core/volume:save_entries.entry.{handler}

This action hook is triggered when a specific volume entry is being saved. It allows you to perform additional actions after the entry has been successfully saved. It is a dynamic hook, where {handler} is replaced with the handler of the entry being saved.

  • Location: src/Core/Volume.php
  • Parameters:
    • mixed $entry: The entry that was saved.
  • Example:
    add_action('a!windpress/core/volume:save_entries.entry.my-custom-theme', function($entry) {
        // Check if the entry's relative-path is 'theme.css'
        if ($entry['relative_path'] === 'theme.css') {
            // Perform save action
            file_put_contents('/path/to/custom/location/theme.css', $entry['content']);
        }
    });