WP HR Employee Leave Management
WordPress HR employee leave management plugin
by HR Management Solutions · github.com/nadimtuhin/wp-hr-employee-leave-management · website
Install
No release zip yet. The repository archive installs, but the folder name will carry the branch suffix and updates will not flow:
wp plugin install https://github.com/nadimtuhin/wp-hr-employee-leave-management/archive/refs/heads/main.zipReadme
WP HR Employee Leave Management
A comprehensive WordPress HR plugin for employee leave management with email approval system, contact memory, and professional workflow automation.
🔗 Repository
GitHub: wp-hr-employee-leave-management
Features
Frontend Features
- Leave Request Form via shortcode
[employee_leave_form] - Multi-type Leave Support - Annual, Casual, Sick, Emergency (Probation)
- Gapped Date Selection - Non-consecutive leave dates
- Real-time Balance Validation - Check available leave before submission
- Manager/Reliever Emails - Optional email fields for notifications
- Responsive Design - Mobile-friendly form interface
- Success Modal - Beautiful modal confirmation after successful submission
- Duplicate Date Validation - Prevents duplicate dates in the same request
- Email Validation - Real-time validation with visual feedback for comma-separated emails
- My Leave Requests Shortcode - Paginated display of employee's leave history with filters
Admin Features
- Modern Dashboard - Statistics overview with visual indicators
- Leave Request Management - Approve/reject with one-click
- Year-based Filtering - Filter requests by year
- Settings Panel - 4 comprehensive tabs:
- General (HR Email configuration & notification settings)
- Leave Types (Manage allocations)
- Email Templates (5 customizable templates)
- Page Management (Create/manage pages)
- Email Notification Control - Enable/disable notifications for submission, approval, and rejection events
Email System
- 5 Email Templates:
- Leave Request Submitted (to HR)
- Leave Request Approved (to employee)
- Leave Request Rejected (to employee)
- Leave Notification Manager (to managers)
- Leave Notification Reliever (to relievers)
- Template Variables:
{{employee_name}},{{leave_dates}},{{leave_types}}, etc. - HTML Email Support with proper formatting
- Configurable Notifications: Admin can enable/disable email notifications for different events
- Automatic Multi-Party Notifications: Emails sent to HR, managers, relievers, and employees based on event type
Installation
- Upload the plugin folder to
/wp-content/plugins/ - Activate the plugin through the 'Plugins' menu in WordPress
- Go to "Employee Leaves" in the admin menu
- Configure settings and create a page with the leave form
Usage
Creating a Leave Request Page
- Go to Employee Leaves > Settings > Page Management
- Enter a page title (e.g., "Employee Leave Request")
- Click "Create Page"
- The page will be created with the shortcode automatically embedded
Manual Shortcode Usage
Leave Request Form: Add [employee_leave_form] to any page or post.
My Leave Requests: Add [my_leave_requests] to any page or post.
Shortcode Attributes:
For Leave Request Form:
title="Custom Title"- Custom form titleshow_balance="false"- Hide balance informationredirect_url="/thank-you"- Custom redirect after submission
For My Leave Requests:
per_page="5"- Number of requests per page (default: 10)show_year_filter="false"- Hide year filtershow_status_filter="false"- Hide status filter
Examples:
[employee_leave_form title="Request Time Off" show_balance="false" redirect_url="/success"]
[my_leave_requests per_page="5" show_year_filter="false"]
Managing Leave Requests
- Go to Employee Leaves > Leave Requests
- Filter by year using the dropdown
- Click "Approve" or "Reject" for pending requests
- View employee details, leave dates, and reasons
Configuring Email Templates
- Go to Employee Leaves > Settings > Email Templates
- Customize subject and body for each template type
- Use template variables for dynamic content
- Enable/disable individual templates
Database Tables
The plugin creates 7 database tables:
wp_employee_leaves_types- Leave type definitionswp_employee_leaves_requests- Main leave requestswp_employee_leaves_dates- Individual leave dates with typeswp_employee_leaves_balances- Yearly leave balances per employeewp_employee_leaves_logs- Activity logs with year trackingwp_employee_leaves_notifications- Email notification logswp_employee_leaves_email_templates- Email template storage
Leave Balance System
- Automatic Initialization - Balances created when first accessed
- Year-based Tracking - Separate balances per year
- Real-time Updates - Balances updated when requests approved
- Balance Validation - Prevents over-allocation during submission
Technical Details
File Structure
wp-employee-leaves/
├── wp-employee-leaves.php (Main plugin file)
├── admin/
│ ├── css/admin.css (Admin styling)
│ └── js/admin.js (Admin JavaScript)
├── frontend/
│ ├── css/style.css (Frontend styling)
│ └── js/script.js (Frontend JavaScript)
├── DEVELOPMENT_PLAN.md (Development roadmap)
├── test-curl.sh (API testing script)
└── README.md (This file)
AJAX Endpoints
wp_ajax_create_leave_page- Create new page with shortcodewp_ajax_add_shortcode_to_page- Add shortcode to existing pagewp_ajax_approve_leave_request- Approve leave requestwp_ajax_reject_leave_request- Reject leave requestwp_ajax_submit_leave_request- Submit new leave request (with proper nonce validation)
Hooks and Filters
employee_leave_form- Shortcode hook- Standard WordPress activation/deactivation hooks
Security Features
- XSS Protection - All user input properly sanitized and output escaped
- Nonce Verification - All forms and AJAX requests protected with WordPress nonces
- Capability Checks - Role-based access control with
manage_optionscapability - SQL Injection Prevention - All database queries use prepared statements
- CSRF Protection - Cross-site request forgery protection on all admin actions
- Input Validation - Comprehensive server-side validation for all user inputs
- Secure Headers - Proper security headers for admin pages
Internationalization
- Text Domain:
wp-employee-leaves - Translation Ready - All strings properly internationalized
- Included Languages: Spanish (es_ES), French (fr_FR)
- JavaScript Localization - Frontend and admin JavaScript strings localized
- Translation Files: .pot, .po, and .mo files included in
/languages/directory
Troubleshooting
Page Creation Issues
- Check browser console for JavaScript errors
- Verify user has 'manage_options' capability
- Ensure plugin is properly activated
- Check WordPress error logs
Email Issues
- Verify HR email is configured in settings
- Check email template settings
- Ensure WordPress mail function is working
- Review email notification logs
Form Submission Issues
- Verify user is logged in
- Check leave balance availability
- Ensure JavaScript is enabled
- Review form validation errors
Support
For issues and feature requests, please check the WordPress admin error logs and browser console for detailed error messages.
Testing
A test script is included for API testing:
# Make the script executable
chmod +x test-curl.sh
# Run tests
./test-curl.sh
The test script includes:
- AJAX endpoint connectivity tests
- Form validation tests
- Authentication tests
- Error handling tests
Note: Update the COOKIES variable in the script with current WordPress session cookies before running.
Version History
-
1.0.0 - Initial release with full functionality
- Leave request form with multi-type support
- Admin dashboard with approval workflow
- Email template system
- Page creation tools
- Modern responsive design
-
1.1.0 - Enhanced user experience and validation
- Added success modal confirmation
- Improved duplicate date validation
- Enhanced email validation with real-time feedback
- Better error handling and AJAX response management
- Added comprehensive test suite
-
1.2.0 - My Leave Requests feature and Email Notifications
- Added [my_leave_requests] shortcode with pagination
- Implemented automatic email notifications for all parties
- Added admin controls for email notification settings
- Enhanced admin dashboard with dual page creation
- Improved notification logging and tracking
-
1.3.0 - Security Hardening and Internationalization
- Comprehensive XSS protection and input sanitization
- Enhanced nonce verification for all AJAX handlers
- Removed debug statements and console.log calls
- Full internationalization support with translation files
- Added Spanish (es_ES) and French (fr_FR) translations
- Security audit and vulnerability remediation
- Improved code quality and WordPress standards compliance