WP-CLI Commands
This document describes the new WP-CLI commands added to Bulldozer for managing autoloaded files.
Commands
wp bulldozer update-includes
This command collects all files loaded by the Bulldozer autoloader and appends them to an $includes array in the child theme's functions.php file.
Usage:
wp bulldozer update-includes
What it does:
- Initializes the Bulldozer autoloader
- Loads files from parent theme, child blocks, and fields
- Collects all loaded file paths
- Converts absolute paths to relative paths (relative to child theme directory)
- Updates or creates an
$includesarray in the child theme'sfunctions.phpfile
Example output:
Success: Successfully updated functions.php with 15 autoloaded files.
Files added to $includes array:
- library/models/post-types/CustomPost.php
- library/controllers/HomeController.php
- library/blocks/hero/hero.php
- library/models/fields/hero-fields.php
Generated code in functions.php:
// Auto-generated includes array by Bulldozer
$includes = [
'library/models/post-types/CustomPost.php',
'library/controllers/HomeController.php',
'library/blocks/hero/hero.php',
'library/models/fields/hero-fields.php',
];
wp bulldozer clear-manifest-cache
Clears the cached site.webmanifest file so it is regenerated on the next page load.
Bulldozer writes the web app manifest to disk and caches a hash of its contents to avoid unnecessary writes. Run this command after changing favicon files or manifest attributes (name, colors, etc.) to force a fresh manifest to be written.
Usage:
wp bulldozer clear-manifest-cache
Example output:
Success: Site icons manifest cache cleared successfully.
wp bulldozer list-files
This command lists all files that would be loaded by the autoloader without modifying any files.
Usage:
wp bulldozer list-files
Example output:
Success: Found 15 autoloaded files:
- library/models/post-types/CustomPost.php
- library/controllers/HomeController.php
- library/blocks/hero/hero.php
- library/models/fields/hero-fields.php
Installation
The WP-CLI commands are automatically registered when Bulldozer is loaded and WP-CLI is available. No additional setup is required.
Use Case
This is particularly useful when you want to:
- Optimize theme performance by replacing autoloading with explicit includes
- Generate a list of all files that your theme depends on
- Create a static include file for production environments
- Debug which files are being loaded by the autoloader
Implementation Details
- The commands use the existing
Autoloaderclass methods - Files are converted to relative paths for portability
- The
$includesarray is added/updated in the child theme'sfunctions.php - If an
$includesarray already exists, it will be replaced - The commands require WP-CLI to be available and WordPress to be loaded