This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
This is a WordPress plugin called ICT Platform that provides a complete operations management system for ICT/electrical contracting businesses. It integrates with Zoho's suite of services (CRM, FSM, Books, People, Desk) for project management, time tracking, resource allocation, inventory management, and procurement with bidirectional synchronization.
- Backend: PHP 8.1+, WordPress 6.4+
- Frontend: React 18+, TypeScript, Redux Toolkit
- Build: Webpack 5, Babel
- Database: MySQL 5.7+ with 7 custom tables
- Testing: PHPUnit, Jest, React Testing Library
- APIs: WordPress REST API + Custom endpoints
- Background Jobs: WordPress Action Scheduler
- Standards: WordPress Coding Standards, ESLint, Prettier
The plugin follows WordPress best practices with separation of concerns:
- Main Entry:
ict-platform.php- Plugin bootstrap and constants - Core System:
includes/- Core classes (Loader, Activator, Core, etc.) - Admin Area:
admin/- Backend admin functionality - Public Area:
public/- Frontend user-facing features - API Layer:
api/- REST endpoints and webhooks - React Apps:
src/- TypeScript React applications - Compiled Assets:
assets/- Built CSS/JS bundles
The plugin uses a custom PSR-4-style autoloader (class-ict-autoloader.php) that maps class prefixes to directories:
ICT_Admin_*→admin/ICT_Public_*→public/ICT_API_*→api/ICT_Model_*→models/ICT_PostType_*→post-types/ICT_Taxonomy_*→taxonomies/ICT_Integration_*→integrations/ICT_Zoho_*→integrations/zoho/ICT_Sync_*→sync/
Class files follow naming convention: class-ict-{name}.php
Seven custom tables (prefix: wp_ict_):
- ict_projects - Project data synced with Zoho CRM deals
- ict_time_entries - Time tracking synced with Zoho People
- ict_inventory_items - Inventory synced with Zoho Books
- ict_purchase_orders - PO workflow synced with Zoho Books
- ict_project_resources - Resource allocation
- ict_sync_queue - Pending sync operations
- ict_sync_log - Sync history and debugging
Table constants defined in main plugin file (e.g., ICT_PROJECTS_TABLE).
Bidirectional sync handled by:
- Queue System:
ICT_Sync_Engineprocessesict_sync_queuetable - Helper Methods:
ICT_Helper::queue_sync()adds items to queue - Cron Jobs: WordPress cron runs sync every 15 minutes
- Service Adapters: Each Zoho service has dedicated adapter class
- Logging: All sync operations logged to
ict_sync_logtable
Rate limiting: 60 requests/minute per Zoho service.
Custom roles created on activation:
- ict_project_manager - Full project and time management access
- ict_technician - Can clock in/out, view assigned projects
- ict_inventory_manager - Inventory and PO management
Capabilities follow pattern: manage_ict_{feature}, edit_ict_{feature}, etc.
- Entry Points: 5 webpack bundles configured:
admin- Admin dashboard (src/admin/index.tsx)public- Public-facing components (src/public/index.tsx)time-tracker- Standalone time tracking app (src/apps/time-tracker/index.tsx)project-dashboard- Project management app (src/apps/project-dashboard/index.tsx)inventory-manager- Inventory management app (src/apps/inventory-manager/index.tsx)
- State Management: Redux Toolkit with 8 slices:
projectsSlice- Project CRUD and filteringtimeEntriesSlice- Time entry managementinventorySlice- Inventory items and stock levelspurchaseOrdersSlice- PO workflow managementresourcesSlice- Resource allocationreportsSlice- Report generationsyncSlice- Sync status and queueuiSlice- UI state (modals, loading, notifications)
- Typed Hooks:
src/store/hooks.tsexportsuseAppDispatchanduseAppSelector - API Layer: Axios services in
src/services/ - Component Structure: Shared components in
src/components/ - Path Aliases:
@components,@hooks,@services,@utils,@types
# Development build with watch
npm run dev
# Production build
npm run build
# Install dependencies
npm install
composer install# Lint JavaScript/TypeScript
npm run lint
npm run lint:fix
# Format code
npm run format
# Check PHP standards
composer phpcs
# Fix PHP standards
composer phpcbf# Run JavaScript tests
npm test
npm run test:watch
npm run test:coverage
# Run PHP tests
composer test
# Type checking
npm run type-check- Create
includes/integrations/zoho/class-ict-zoho-{service}-adapter.php - Implement methods:
authenticate(),create(),update(),delete(),test_connection() - Add OAuth settings in
class-ict-admin-settings.php - Register in integration manager
- Add route in
api/class-ict-api.phpin appropriateregister_*_routes()method - Create handler method following naming convention
- Add permission callback
- Create controller class in
api/rest/for complex logic
- Create class in
includes/post-types/class-ict-posttype-{name}.php - Extend pattern from
class-ict-posttype-project.php - Register in
class-ict-core.phpdefine_admin_hooks()method
- Update
class-ict-activator.phpcreate_tables()method - Add new table SQL
- Define table constant in
ict-platform.php - Increment DB version option
- Add component file in appropriate
src/subdirectory - Use TypeScript interfaces for props
- Export from nearest
index.ts - Add tests in
__tests__/directory
Assets only load on relevant admin pages (checked via is_ict_admin_page()) or public pages with shortcodes/templates.
// Add item to sync queue
ICT_Helper::queue_sync( array(
'entity_type' => 'project',
'entity_id' => $id,
'action' => 'update', // create, update, delete
'zoho_service' => 'crm', // crm, fsm, books, people, desk
'priority' => 5, // 1-10, lower is higher priority
'payload' => $data,
) );ICT_Helper::log_sync( array(
'entity_type' => 'project',
'entity_id' => $id,
'direction' => 'outbound', // outbound or inbound
'zoho_service' => 'crm',
'action' => 'update',
'status' => 'success', // success or error
'request_data' => $request,
'response_data' => $response,
'error_message' => null,
'duration_ms' => $duration,
) );ICT_Helper::format_currency()- Format money valuesICT_Helper::calculate_hours()- Time calculationsICT_Helper::round_time()- Round to nearest intervalICT_Helper::is_overtime()- Check overtime statusICT_Helper::generate_project_number()- Auto-generate project numbersICT_Helper::sanitize_coordinates()- GPS validation
- All Zoho credentials encrypted using OpenSSL AES-256-CBC
- Decryption via
ICT_Admin_Settings::decrypt() - REST API uses WordPress nonce verification
- All database inputs sanitized, outputs escaped
- Capabilities checked for all privileged operations
- PHP: Unit tests for helpers and utility functions
- React: Component tests with React Testing Library
- Integration: Test Zoho sync flows end-to-end
- Coverage Target: 70%+ for all metrics
- Run
npm run buildfor production assets - Ensure all tests pass
- Update version in
ict-platform.phpandpackage.json - Create zip excluding
node_modules/,src/,tests/,.git/ - Test activation in clean WordPress environment
- Sync queue processes maximum 20 items per cron run (prevent timeout)
- Failed sync items retry up to 3 times before marking as failed
- Sync logs older than 30 days automatically cleaned up
- OAuth tokens auto-refresh when expired
- Rate limiting enforced per Zoho service (60 req/min)
- PWA features enabled for offline time tracking
- GPS tracking optional, can be disabled in settings
- Main plugin file:
ict-platform.php - Activation logic:
includes/class-ict-activator.php - Core bootstrap:
includes/class-ict-core.php - Admin menu:
admin/class-ict-admin-menu.php - Settings:
admin/class-ict-admin-settings.php - REST API:
api/class-ict-api.php - Sync engine:
includes/sync/class-ict-sync-engine.php - Integration manager:
includes/integrations/class-ict-integration-manager.php - Helper utilities:
includes/class-ict-helper.php - Webpack config:
webpack.config.js - TypeScript config:
tsconfig.json
class-ict-zoho-crm-adapter.php- CRM deals and contacts syncclass-ict-zoho-fsm-adapter.php- Field service managementclass-ict-zoho-books-adapter.php- Accounting and invoicingclass-ict-zoho-people-adapter.php- HR and time trackingclass-ict-zoho-desk-adapter.php- Support tickets
class-ict-quotewerks-adapter.php- Quote managementclass-ict-microsoft-teams-adapter.php- Teams notifications
- Project Management: Project templates, milestones, recurring tasks
- Time & Attendance: Extended time tracking, GPS tracking, biometric auth
- Financial: Budget tracker, profitability analysis, multi-currency, invoice generator
- Inventory: Inventory alerts, equipment manager, supplier manager
- Communication: Messaging, push notifications, announcements, email templates
- Reporting: KPI tracker, report builder, advanced reporting, data export
- Security: Two-factor auth, audit log, API rate limiter, advanced role manager
- Customer: Client portal, satisfaction surveys, SLA tracking, warranty tracker
- Operations: Resource scheduler, PO approval workflow, calendar sync
- System: System health monitoring, webhook manager, import wizard, global search, notification center, custom field builder, offline manager, document manager, activity feed, dashboard widgets, certification tracker, field media capture
Phases 1-7 are substantially complete. Remaining work:
- Testing: Add Jest unit tests for React components
- PHP Tests: Add PHPUnit tests for feature modules
- Documentation: API documentation and user guides
- Performance: Optimize bundle sizes and lazy loading
- Mobile: PWA enhancements for field technicians