Install
This is the repository archive. It installs, but the folder name will carry the branch suffix and updates will not flow.
Install straight from GitHub with WP-CLI:
wp plugin install https://github.com/julianescobar/wp-hr-leave-manager/archive/refs/heads/main.zipNo built-in updater. New versions won't appear under Dashboard → Updates. Install new releases yourself, or let Git Updater track the repository.
WordPress plugin for HR leave and vacation management. REST API integration, configurable approval workflows, balance accrual, and admin reports.
Architecture
src/
├── Contracts/ — Repository interfaces (Dependency Inversion)
├── Exceptions/ — Domain exceptions (InsufficientBalance, Overlap, etc.)
├── Models/ — Value objects and enums (LeaveType, ContractType, etc.)
├── Repositories/ — Data access implementing Contracts
├── Services/ — Business logic (Leave, Accumulation, Calendar, API)
├── Admin/ — Admin pages (dashboard, reports, settings)
├── Hooks/ — Public hooks and admin-post handlers
├── PostTypes/ — Custom post type registration
└── Core/ — Bootstrap, DI container
Patterns: Service Layer, Repository, Dependency Injection, Hook-based extensibility.
Key decisions:
- Repository interfaces in
Contracts/so services depend on abstractions, not concretions - Custom exceptions instead of error arrays — cleaner error handling, testable with
expectException - PHP 8.1+ enums for
LeaveType,ContractType, andLeaveStatusas value objects - CPT + native meta for leave request storage (no ACF dependency)
- All SQL via
$wpdb->prepare()— zero injection risk
Hooks
do_action('hr_vacation_request_submitted', $requestId, $employeeId, $leaveType, $startDate, $endDate, $days);
do_action('hr_vacation_request_status_changed', $requestId, $newStatus, $oldStatus);
do_action('hr_vacation_request_approved', $requestId);
do_action('hr_vacation_request_rejected', $requestId, $reason);
apply_filters('hr_working_days_calculation', $days, $start, $end, $holidays);
Requirements
- PHP 8.1+
- WordPress 6.0+
Installation
git clone git@github.com:julianescobar/wp-hr-leave-manager.git
cd wp-hr-leave-manager
composer install
Activate from WordPress Admin → Plugins.
Configuration
HR Leave → Settings:
- API Key — Authentication key for external HR API
- API URL — Base URL of the external REST API
- Holidays — One date per line (YYYY-MM-DD), excluded from working day calculation
Business Rules
| Rule | Implementation |
|---|---|
| No Overlap | findOverlapping() SQL query + validateNoOverlap() |
| Blackout Dates | CalendarService::calculateWorkingDays() excludes configured holidays |
| Priority Types | Sick/Maternity skip advance notice, balance check, and non-priority overlap |
| Concurrent Limit | validatePendingLimit() rejects if any pending request exists |
| Advance Notice | 5-day minimum enforced in validateAdvanceNotice() |
| Balance Check | validateBalance() compares requested days vs accrued balance |
Testing
composer test
8 test suites, 28 tests covering all business rules and edge cases.
License
GPL-2.0+