# WebEquipe PDF Search

WordPress plugin that indexes PDFs into native search — see `.ai-context/PROJECT.md` for full context.

## Strict Rules

1. ABSPATH guard on every PHP file: `if ( ! defined( 'ABSPATH' ) ) { exit; }`
2. Never delete under `release/` — fix tool config instead
3. Backup before any delete — copy to `backup/YYYY-MM-DD_HHMMSS/` first
4. WordPress security: sanitize input, escape output, `$wpdb->prepare()` for dynamic SQL, nonces on AJAX, `manage_options` for admin
5. No `esc_sql()` for table names — trusted `$wpdb->prefix` + hardcoded suffix only
6. PHPCS must pass (`composer phpcs`) — see phpcs.xml.dist for documented WPCS exclusions
7. Text domain `webequipe-pdf-search` on all user-facing strings
8. Do not remove Pro coexistence guard in webequipe-pdf-search.php
9. Do not commit `backup/` or `vendor/`

## Naming

| Type | Convention | Example |
|------|------------|---------|
| Namespace | `WebEquipe\PDFSearch` | All classes in `includes/` |
| Classes | `PascalCase` with underscore | `PDF_Indexer`, `Admin_Settings` |
| Class files | `class-{kebab}.php` | `class-pdf-indexer.php` |
| Functions | `webequipe_pdf_search_*` | `webequipe_pdf_search_log()` |
| Constants | `WEBEQUIPE_PDF_SEARCH_*` | `WEBEQUIPE_PDF_SEARCH_VERSION` |
| Hooks | `webequipe_pdf_search_*` | `webequipe_pdf_search_before_index` |
| Options | `webequipe_pdf_search_*` | `webequipe_pdf_search_settings` |
| Post meta | `_webequipe_pdf_*` | `_webequipe_pdf_search_excluded` |
| CSS | `webequipe-pdf-*` | `webequipe-pdf-result` |
| AJAX | `webequipe_pdf_*` | `webequipe_pdf_scan_pdfs` |
| DB tables | `{prefix}webequipe_pdf_search_*` | `webequipe_pdf_search_pages` |

## Key Patterns

- Static `Database` methods — no ORM; `dbDelta()` for schema
- `require_once` for core class loading; Composer for smalot/pdfparser + Freemius
- Settings in single option `webequipe_pdf_search_settings`
- Admin views in `admin/views/`; AJAX via `wp_send_json_success`/`error`
- Excluded PDFs (`_webequipe_pdf_search_excluded`) skipped in bulk/auto index
- Poppler pdftotext preferred, smalot/pdfparser fallback for text extraction

## Feature Addition Steps

1. Read `.ai-context/ARCHITECTURE.md` and relevant `modules/*.md`
2. Branch from `develop` (`feature/short-description`)
3. Add logic in `includes/`, views in `admin/views/` if needed
4. Register hooks in class constructor or `webequipe-pdf-search.php`
5. Schema changes: update `Database::create_*_table()` + version migration
6. AJAX: add handler in `Admin_Settings` with nonce + `manage_options`
7. Run `composer phpcs` / `composer phpcbf`
8. Always update `.ai-context/FEATURES.md` and `.ai-context/CHANGELOG.md`
9. Update `docs/DEVELOPER.md` if public developer API changes
10. Open PR to `develop`
