Development
Add-on Development – Guide to building add-on plugins for Virtual Media Folders.
# Add to composer.jsoncomposer require soderlind/virtual-media-folderscomposer require soderlind/vmfa-rules-engine
# Install dependenciescomposer installnpm install# Start development build with watchnpm run start
# Production buildnpm run build# Lint JavaScriptnpm run lint:js
# Lint CSSnpm run lint:css
# Lint PHP (WordPress Coding Standards)composer lint:phpcomposer fix:php# PHP tests (PHPUnit with Brain Monkey)composer testcomposer test:coverage # With HTML coverage report
# JavaScript tests (Vitest)npm testnpm run test:watch # Watch modenpm run test:coverage # With coverage reportHooks & Filters
Section titled “Hooks & Filters”Actions
Section titled “Actions”vmfa_rules_engine_folder_assigned— Fired after a rule assigns a folder- Parameters:
$attachment_id,$folder_id,$rule
- Parameters:
Filters
Section titled “Filters”vmfa_rules_engine_matchers— Add custom condition matchersvmfa_rules_engine_skip_if_assigned— Skip rule evaluation if folder already assigned
Example: Custom Condition Matcher
Section titled “Example: Custom Condition Matcher”add_filter( 'vmfa_rules_engine_matchers', function( $matchers ) { $matchers['custom_type'] = new My_Custom_Matcher(); return $matchers;} );
class My_Custom_Matcher implements \VmfaRulesEngine\Conditions\MatcherInterface { public function matches( $attachment_id, $metadata, $params ) { // Your custom logic return true; }
public function get_type() { return 'custom_type'; }}REST API Endpoints
Section titled “REST API Endpoints”All endpoints require manage_options capability.
| Method | Endpoint | Description |
|---|---|---|
| GET | /vmfa-rules/v1/rules | List all rules |
| POST | /vmfa-rules/v1/rules | Create a rule |
| GET | /vmfa-rules/v1/rules/{id} | Get a single rule |
| PUT | /vmfa-rules/v1/rules/{id} | Update a rule |
| DELETE | /vmfa-rules/v1/rules/{id} | Delete a rule |
| POST | /vmfa-rules/v1/rules/reorder | Reorder rules |
| POST | /vmfa-rules/v1/preview | Scan existing media (preview) |
| POST | /vmfa-rules/v1/apply-rules | Apply rules to media |
| GET | /vmfa-rules/v1/stats | Get media library statistics |
📦 Source: soderlind/vmfa-rules-engine · Edit on GitHub