# CLAUDE.md

This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.

## WordPress Plugin Architecture

This is the **Advanced Category Manager** WordPress plugin with the following structure:

- **Main Plugin File**: `better-category-manager.php` - Entry point, defines constants and initializes classes
- **Core Classes**: Located in `includes/` directory using namespace `BCATM\`
  - `Admin` - Handles admin interface and menu registration
  - `Settings` - Manages plugin settings and configuration
  - `Ajax_Handler` - Processes AJAX requests with proper nonce validation
  - `Import_Export` - Handles category import/export functionality
  - `OpenAI_Integration` - AI-powered term suggestions (optional feature)

All core classes use singleton pattern with `get_instance()` method.

## Development Commands

### Main Package (Root Directory)
- `npm run build` - Build production assets
- `npm run build:zip` - Build and create zip package
- `npm run test` - Run build tests
- `npm run test:all` - Comprehensive testing (GitHub, SVN, versions)
- `npm run release` - Interactive release process
- `npm run release:github` - Release to GitHub only
- `npm run release:svn` - Release to WordPress.org SVN only
- `npm run release:both` - Release to both platforms
- `npm run translate` - Update translation files
- `npm run svn-tags` - Manage SVN tags
- `npm run delete-tag` - Remove specific tags

### Scripts Directory
First run `cd scripts && npm install` to install script dependencies.

- `cd scripts && npm run translate` - Generate/update translation files
- `cd scripts && npm run commit` - Interactive commit helper
- `cd scripts && npm run build` - Build from scripts directory
- `cd scripts && npm run release` - Release from scripts directory

## Build System

The build system (`scripts/build.js`) creates production-ready packages by:
- Excluding development files (node_modules, scripts, .git, etc.)
- Creating timestamped builds in `build/` directory
- Generating zip packages in `dist/` directory
- Managing SVN repository synchronization

## Constants and File Structure

Key plugin constants defined in main file:
- `BCATM_VERSION` - Plugin version (currently 1.0.3)
- `BCATM_PLUGIN_DIR` - Plugin directory path
- `BCATM_PLUGIN_URL` - Plugin URL
- `BCATM_INCLUDES_DIR` - Classes directory
- `BCATM_ASSETS_URL` - Assets URL
- `BCATM_TEMPLATES_DIR` - Template files

## Environment Configuration

Create `scripts/.env` file with:
```
GITHUB_TOKEN=your_github_token
GITHUB_OWNER=your_github_username
```

## Git Workflow

- Main development branch: `develop`
- Create feature branches from `develop`
- Use `npm run commit` for interactive commits
- Release process automatically handles version bumping and tagging

## WordPress Integration

- **Text Domain**: `better-category-manager`
- **Minimum PHP**: 7.4
- **Minimum WordPress**: 5.8
- Admin pages accessible under Posts menu
- Settings page at `admin.php?page=BCATM-settings`
- Category manager at `edit.php?page=BCATM-manager`

## AJAX Security

All AJAX requests use nonce validation with key `BCATM_nonce`. Handler methods follow pattern:
- Verify nonce
- Check user capabilities
- Process request
- Return JSON response

## Translation System

- POT file: `languages/better-category-manager.pot`
- Use `npm run translate` to update translations
- Translation scripts located in `scripts/translations/`