diff --git a/.github/workflows/test-and-release.yml b/.github/workflows/test-and-release.yml index ba04c12..e44f5d6 100644 --- a/.github/workflows/test-and-release.yml +++ b/.github/workflows/test-and-release.yml @@ -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: @@ -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 @@ -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 @@ -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 diff --git a/CLAUDE.md b/CLAUDE.md new file mode 100644 index 0000000..6cc1da1 --- /dev/null +++ b/CLAUDE.md @@ -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-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.