File Scanning

The File Scanning feature automatically extracts CSS classes from your theme files, CSS files, JavaScript files, and any other files containing class definitions. This powerful tool helps you discover and use all available classes in your WordPress installation.

🎯 Overview

File Scanning provides:

  • Automatic Discovery: Find classes in CSS files
  • Background Processing: Non-blocking scans that won’t slow down your site
  • Automatic Triggers: Scan when specific post types are saved
  • Flexible Selection: Choose specific files or entire directories
  • Real-time Updates: New classes immediately available in autocomplete

🏗️ How File Scanning Works

Supported File Types

The scanner can extract classes from:

  • CSS Files: .css – You can select each css file separatly
  • Folder: You can select folder and it will scan for all .css files inside that folder

Scanning Process

  1. File Selection: Choose files/folders to scan
  2. Background Processing: Scan runs asynchronously
  3. Class Extraction: Parse files for CSS class patterns
  4. Database Storage: Store found classes with “Scanned” type
  5. Autocomplete Update: Classes immediately available

🚀 Manual Scanning

Accessing File Scanner

Navigate to Tools → Plain Classes Gutenberg → Scan Classes

Interface Overview

File Tree Explorer:

  • Browse your WordPress installation
  • Select individual files or entire folders
  • Visual icons distinguish files from folders
  • Real-time path selection

Selected Paths Panel:

  • View currently selected scan targets
  • Remove individual paths
  • Clear all selections

Scan Controls:

  • “Scan Selected Files” button
  • Progress indicator during scanning
  • Results summary after completion

Selecting Files for Scanning

Method 1: Individual Files

  1. Navigate through file tree
  2. Click on specific files to select
  3. File appears in “Selected Paths” list
  4. Repeat for multiple files

Method 2: Entire Folders

  1. Click on folder names in tree view
  2. Entire folder and subfolders selected
  3. Efficient for theme/plugin directories
  4. Can combine with individual files

Running Manual Scans

  1. Select Target Files/Folders

    • Use file tree to choose scan targets
    • Verify selections in “Selected Paths” panel
  2. Start Scanning

    • Click “Scan Selected Files” button
    • Progress bar shows scanning status
    • Process runs in background
  3. Review Results

    • Scan completion message appears
    • Number of new classes found
    • Classes immediately available in autocomplete

🔄 Automatic Scanning

Post-Save Triggers

The plugin can automatically scan files when certain post types are saved:

Supported Save Methods:

  • ✅ WordPress “Update” button
  • ✅ Keyboard shortcuts (Ctrl+S/Cmd+S via Scripts Organizer)

Default Trigger:

  • Post Type: scorg (Scripts Organizer posts)
  • When: Every time post is saved
  • What: Scans your selected files/folders

Intelligent Filtering

Valid Class Detection:

  • Filters out CSS properties that aren’t classes
  • Removes pseudo-selectors and media queries
  • Excludes JavaScript variables that look like classes
  • Validates class name format

Duplicate Prevention:

  • Checks against existing classes before adding
  • Merges results from multiple files
  • Prevents redundant database entries

Integration Hooks

Before Scan:

add_action('pcguten_before_scan', function($file_paths) {
    // Custom logic before scanning
});

After Scan:

add_action('pcguten_after_scan', function($found_classes, $file_paths) {
    // Process results
});

Filter Classes:

add_filter('pcguten_scanned_classes', function($classes, $file_path) {
    // Modify found classes before storage
    return $classes;
}, 10, 2);