Winden

Class names hook

If collecting class names from our current integration is not enough, Winden from v2.6.1 have a hook for adding additional class names.

The hook system is implemented through WordPress’s filter mechanism using the winden_register_crawlers hook. When Winden collects classes, it calls this hook to gather additional classes from registered crawlers.

Code example:

Bellow is and example of the plugin that will inject two extra class names.

<?php
/**
 * Plugin Name: Winden Classes Crawler Hook
 * Description: Adds custom classes to Winden's class collection
 * Version: 1.0.0
 * Author: DPlugins
 */

// Prevent direct access to this file
if (!defined('ABSPATH')) {
    exit;
}

/**
 * Custom Crawler Class for Winden
 * 
 * This class implements a custom crawler that adds specific Tailwind CSS classes
 * to Winden's class collection. These classes will appear in the autocomplete
 * suggestions across all supported page builders (Elementor, Oxygen, etc.).
 */
class WindenCustomClassesCrawler
{
    /**
     * Returns an array of CSS classes to be added to Winden's collection
     * 
     * This method is called by Winden's HookCrawler when collecting all available
     * classes. Any classes returned here will be:
     * - Added to Winden's class collection
     * - Available in the autocomplete suggestions
     * - Included in the final CSS output if used
     * 
     * @return array Array of CSS class names
     */
    public function classes(): array
    {
        return [
            'bg-red-300',  // Tailwind class for light red background
            'bg-blue-500'  // Tailwind class for medium blue background
        ];
    }
}

/**
 * Register our custom crawler with Winden
 * 
 * This filter hook 'winden_register_crawlers' is provided by Winden to allow
 * other plugins to add their own crawlers. The hook:
 * - Receives an array of existing crawlers
 * - Expects the array to be returned with any new crawlers added
 * - Is processed by Winden's HookCrawler class
 */
add_filter('winden_register_crawlers', function($crawlers) {
    $crawlers[] = new WindenCustomClassesCrawler();
    return $crawlers;
});

Table of Contents