|
| 1 | +# AI Agent Guide — Custom Fonts |
| 2 | + |
| 3 | +## Quick Start for AI Agents |
| 4 | + |
| 5 | +1. **Entry point:** Start at `custom-fonts.php` to understand plugin initialization |
| 6 | +2. **Constants:** Look for `define()` calls in the main file for paths and versions |
| 7 | +3. **Hook registration:** Search for `add_action` and `add_filter` to find where functionality is attached |
| 8 | +4. **Text domain:** Use `custom-fonts` for all translatable strings |
| 9 | + |
| 10 | +## Common Tasks |
| 11 | + |
| 12 | +### Adding a new feature |
| 13 | +1. Create a new class file in the appropriate directory |
| 14 | +2. Register it via `require_once` in the loader or main class |
| 15 | +3. Use `add_action`/`add_filter` to hook into WordPress |
| 16 | +4. Follow existing class patterns for consistency |
| 17 | + |
| 18 | +### Modifying existing behavior |
| 19 | +1. Find the relevant class by searching for the hook or function name |
| 20 | +2. Check for filters that allow modification without editing core files |
| 21 | +3. If editing, maintain the existing code style and patterns |
| 22 | + |
| 23 | +### Adding translatable strings |
| 24 | +1. Wrap strings in `__( 'text', 'custom-fonts' )` or `esc_html__( 'text', 'custom-fonts' )` |
| 25 | +2. Run `npx grunt i18n` to update the POT file |
| 26 | + |
| 27 | +## WordPress Checklist |
| 28 | + |
| 29 | +- [ ] All output is escaped (`esc_html`, `esc_attr`, `esc_url`, `wp_kses`) |
| 30 | +- [ ] All input is sanitized (`sanitize_text_field`, `absint`, etc.) |
| 31 | +- [ ] Nonces used for forms and AJAX (`wp_nonce_field`, `check_ajax_referer`) |
| 32 | +- [ ] Capability checks before privileged operations (`current_user_can`) |
| 33 | +- [ ] Text domain `custom-fonts` used for all user-facing strings |
| 34 | +- [ ] No direct file access (files start with `defined( 'ABSPATH' )` check or silence) |
| 35 | + |
| 36 | +## Pitfalls |
| 37 | + |
| 38 | +- Plugin may depend on Astra theme being active — check for theme dependency logic |
| 39 | +- Constants are defined only once — don't redefine them |
| 40 | +- Follow WordPress coding standards (spaces not tabs for alignment, tabs for indentation) |
0 commit comments