This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
WP Tag Order is a WordPress plugin that enables drag-and-drop ordering of tags (non-hierarchical taxonomies) within individual posts. It stores tag order metadata and provides both PHP APIs and REST endpoints for managing tag order.
- Use pnpm (not npm) for all package operations
pnpm run dev- Development build with watch modepnpm run build- Production buildpnpm run lint- Lint TypeScript filespnpm run lint:fix- Auto-fix linting issuespnpm run lint:css- Lint CSS filespnpm run type-check- TypeScript type checking
composer run phpstan- Run PHPStan static analysis- PHPUnit tests located in
/testsdirectory
- Main plugin file:
wp-tag-order.php- Entry point with PHP version checking - Core logic:
/includesdirectoryfunctions.php- Utility functions and constantsclass-tag-updater.php- Programmatic API classrest-api.php- REST endpoint handlerscategory-template.php- Template function overridesindex.php- Admin interface logic
- Source:
/src/assets/- TypeScript files in
/tssubdirectory - CSS files in
/csssubdirectory
- TypeScript files in
- Build: Uses rspack (not webpack) for compilation
- Output: Compiled assets to
/assets/jsand/assets/css
- Namespace:
WP_Tag_Order\ - Key class:
Tag_Updater- Provides programmatic tag order management
- Tag order stored in
wp_postmetatable - Meta key pattern:
wp-tag-order-{taxonomy} - Value: Serialized array of ordered tag IDs
- PHP: 8.0+ (strictly enforced with version checking)
- WordPress: 5.6+
- Supported: Non-hierarchical taxonomies and built-in tags
- Not supported: Hierarchical taxonomies (categories)
- PHP: WordPress Coding Standards (WPCS), PHPStan analysis
- JavaScript/TypeScript: Biome
- CSS: StyleLint
get_the_tags_ordered()- Get ordered tags for current postget_the_terms_ordered($post_id, $taxonomy)- Get ordered termsget_the_tag_list_ordered()- Get formatted tag listget_the_term_list_ordered()- Get formatted term list
$updater = new \WP_Tag_Order\Tag_Updater();
$result = $updater->update_tag_order($post_id, $taxonomy, $tag_ids);- Base:
/wp-json/wp-tag-order/v1/ - Get order:
GET /tags/order/{post_id} - Update order:
PUT /tags/order/{post_id}
WPTAGORDER_META_KEY_PREFIX- 'wp-tag-order-'WPTAGORDER_REST_NAMESPACE- 'wp-tag-order/v1'WPTAGORDER_OPTION_ENABLED_TAXONOMIES- 'wpto_enabled_taxonomies'