|
| 1 | +# CLAUDE.md |
| 2 | + |
| 3 | +This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. |
| 4 | + |
| 5 | +## Project Overview |
| 6 | + |
| 7 | +Disciple.Tools is a WordPress theme that functions as a CRM for Christian ministries managing discipleship and church growth. It's not a typical theme—it's a full application built on WordPress. |
| 8 | + |
| 9 | +## Common Commands |
| 10 | + |
| 11 | +### Build & Development |
| 12 | +```bash |
| 13 | +npm install # Install dependencies and run build |
| 14 | +npm run build # Build CSS/JS (runs gulp) |
| 15 | +``` |
| 16 | + |
| 17 | +### Linting |
| 18 | +```bash |
| 19 | +npm run lint # Run ESLint |
| 20 | +npm run prettier # Format JS files with Prettier |
| 21 | +composer install # Install PHP dependencies (required for PHPCS) |
| 22 | +./tests/test_phpcs.sh # Run PHP CodeSniffer |
| 23 | +./tests/test_phpcs.sh file.php # Run PHPCS on specific files |
| 24 | +./vendor/bin/phpcbf # Auto-fix PHPCS errors |
| 25 | +./tests/test_eslint.sh # Run ESLint + Prettier check |
| 26 | +``` |
| 27 | + |
| 28 | +## Architecture |
| 29 | + |
| 30 | +### Core Module Structure |
| 31 | +The theme is organized into `dt-*` directories, each representing a major feature module: |
| 32 | + |
| 33 | +- **dt-posts/** - Generic post type CRUD system. `DT_Posts` class provides `create_post()`, `update_post()`, `get_post()`, `list_posts()` for any registered post type |
| 34 | +- **dt-contacts/** - Contact post type and contact-specific logic |
| 35 | +- **dt-groups/** - Groups post type |
| 36 | +- **dt-users/** - User management, permissions, and user-related endpoints |
| 37 | +- **dt-notifications/** - Notification system with email queue |
| 38 | +- **dt-metrics/** - Dashboard metrics and charts |
| 39 | +- **dt-mapping/** - Location/mapping functionality |
| 40 | +- **dt-people-groups/** - People groups post type |
| 41 | +- **dt-login/** - Authentication, including SSO methods |
| 42 | +- **dt-workflows/** - Automation workflows |
| 43 | +- **dt-reports/** - Magic links system for public-facing forms |
| 44 | +- **dt-core/** - Shared utilities, configuration, libraries, and admin functionality |
| 45 | +- **dt-assets/** - Frontend assets (JS, SCSS, images) |
| 46 | + |
| 47 | +### Key Patterns |
| 48 | + |
| 49 | +**Post Type Registration**: Custom post types extend `DT_Module_Base` and register via `dt_registered_post_types` filter. |
| 50 | + |
| 51 | +**Field Definitions**: Post type fields are defined via `dt_custom_fields_settings` filter. Field types include: text, textarea, number, date, key_select, multi_select, tags, connection, location, user_select, communication_channel. |
| 52 | + |
| 53 | +**REST API**: Endpoints follow pattern `/dt-posts/v2/{post_type}/` and `/dt/v1/` namespaces. All REST endpoints require authentication by default. |
| 54 | + |
| 55 | +**Frontend Build** (see `gulpfile.js`): |
| 56 | +- SCSS from `dt-assets/scss/` and `@disciple.tools/web-components/src/styles/` compile to `dt-assets/build/css/` |
| 57 | +- JS from what-input, Foundation core + plugins, `dt-assets/js/footer-scripts.js`, and masonry concatenate to `dt-assets/build/js/scripts.min.js` |
| 58 | +- Web components JS from `@disciple.tools/web-components/dist/` copy to `dt-assets/build/components/` |
| 59 | + |
| 60 | +### Important Files |
| 61 | + |
| 62 | +- `functions.php` - Main entry point, loads all modules |
| 63 | +- `dt-core/global-functions.php` - Globally available utility functions |
| 64 | +- `dt-posts/dt-posts.php` - Core CRUD operations for all post types |
| 65 | +- `dt-core/configuration/config-site-defaults.php` - Default site configuration |
| 66 | +- `dt-core/configuration/class-roles.php` - User roles and capabilities |
| 67 | + |
| 68 | +### Documentation |
| 69 | + |
| 70 | +See `docs/` for detailed API documentation: |
| 71 | +- `dt-posts-api-reference.md` - DT_Posts API reference |
| 72 | +- `dt-posts-field-formats.md` - Field value formats for create/update |
| 73 | +- `dt-posts-field-settings.md` - How to define field settings |
| 74 | +- `dt-posts-list-query.md` - Query parameters for list_posts() |
| 75 | +- `dt-magic-links.md` - Magic links system |
| 76 | +- `dt-database-schema.md` - Database schema |
| 77 | + |
| 78 | +## Code Style |
| 79 | + |
| 80 | +- **PHP**: WordPress coding standards with 4-space indentation (not tabs). Run PHPCS to check. |
| 81 | +- **JS**: ESLint + Prettier. Don't use `_.` for lodash (conflicts with underscore). |
| 82 | +- **Translations**: All user-facing strings must be translatable using `esc_html_e()`, `__()`, etc. with text domain `disciple_tools`. |
| 83 | + |
| 84 | +## Pre-commit Hooks |
| 85 | + |
| 86 | +Husky runs lint-staged on commit: |
| 87 | +- PHP files: `./phpcbf.sh` (auto-fix) |
| 88 | +- JS files: ESLint + Prettier |
| 89 | + |
| 90 | +## CI Requirements |
| 91 | + |
| 92 | +Pull requests must pass: |
| 93 | +1. PHP syntax check |
| 94 | +2. PHPCS on changed PHP files |
| 95 | +3. ESLint + Prettier |
| 96 | +4. Gulp build (minified files must match) |
| 97 | +5. PHPUnit tests (multisite mode) |
0 commit comments