Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions .github/workflows/test-and-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@ name: Test and Release
on:
pull_request:
push:
branches: [ master ]
tags: ['*']
branches: [master]
tags: ["*"]

jobs:

test:
runs-on: ubuntu-latest
services:
Expand Down Expand Up @@ -63,6 +62,9 @@ jobs:
- name: Composer install
run: composer update --optimize-autoloader --prefer-dist

- name: Install subversion
run: sudo apt-get update && sudo apt-get install -y subversion

- name: Install WP Tests
run: bash bin/install-wp-tests.sh wordpress_test root root 127.0.0.1 ${{ matrix.wp }} true

Expand All @@ -76,7 +78,7 @@ jobs:
WP_MULTISITE=1 composer test

lint:
runs-on: ubuntu-latest
runs-on: ubuntu-latest
name: PHP lint
steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -106,7 +108,7 @@ jobs:
release:
name: Release
runs-on: ubuntu-latest
needs: [test,lint]
needs: [test, lint]
steps:
- uses: actions/checkout@v4
- name: Build
Expand Down
76 changes: 76 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# CLAUDE.md

This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.

## Project Overview

**Custom Post Type Permalinks** is a WordPress plugin that allows editing the permalink structure of custom post types. It is listed in the official WordPress.org plugin directory.

## Commands

### Testing

WordPress test environment setup is required before running tests:

```bash
bash bin/install-wp-tests.sh <db-name> <db-user> <db-pass> [db-host] [wp-version]
# Example: bash bin/install-wp-tests.sh wordpress_test root root 127.0.0.1 trunk
```

```bash
# Run tests
composer test

# Run tests in multisite mode
WP_MULTISITE=1 composer test
```

### Lint / Code Quality

```bash
# PHPCS check (WordPress Coding Standards)
composer phpcs

# Auto-format
composer format
```

## Architecture

### Design Pattern

The plugin uses a **singleton + modular architecture**:

- `custom-post-type-permalinks.php` — Plugin entry point. Defines constants and class autoloader.
- `CPTP.php` — Singleton main class. Initializes modules sequentially via `CPTP::get_instance()->init()`.
- `CPTP/Module.php` — Abstract base class for all modules.
- `CPTP/Util.php` — Utility functions for retrieving post types, checking rewrite support, etc.

### Modules (`CPTP/Module/`)

| Module | Responsibility |
|--------|---------------|
| `Setting` | Text domain loading, version management |
| `Rewrite` | Registers rewrite rules for custom post types and taxonomies |
| `Admin` | Settings UI (Settings → Permalinks) |
| `Option` | Saves permalink structure options |
| `Permalink` | Generates permalinks for posts, terms, and archives |
| `GetArchives` | Supports `wp_get_archives()` |
| `FlushRules` | Handles rewrite rule flushing |

To add or modify modules, use the `CPTP_load_modules` / `cptp_load_modules` hooks.

### Coding Standards

- Prefix: `CPTP`
- Text domain: `custom-post-type-permalinks`
- WordPress Coding Standards (including Yoda conditions)
- PHP 7.4+

### Tests

PHPUnit tests under `tests/`. `tests/bootstrap.php` initializes the WordPress test environment and Yoast PHPUnit Polyfills.

### CI/CD

`.github/workflows/test-and-release.yml` runs tests across PHP 7.4/8.0/8.2 and WP trunk/6.5/6.1. Automatically deploys to WordPress.org on tag creation.
Loading