Skip to content

Conversation

@soderlind
Copy link
Owner

This pull request introduces several important enhancements and fixes to the WP Loupe plugin, focusing on schema migration, plugin auto-update management, improved test coverage, and REST API robustness. The most notable changes include a migration routine to ensure the presence of the post_date field in all indexes, a new settings-driven auto-update toggle, and expanded tests and documentation. Additionally, the REST API handler is now more robust and testable.

Schema Migration & Indexing Improvements

  • Added a new WP_Loupe_Migration class to ensure the post_date field exists for all post types, automatically migrating older installations and triggering a reindex (inline for ≤2000 posts, scheduled otherwise). Admins can opt out via WP_LOUPE_DISABLE_AUTO_REINDEX.
  • Modified WP_Loupe_Indexer to include a migration helper (ensure_required_columns) that checks and adds the post_date column and index to the SQLite documents table if missing, preventing fatal errors on upgrade. [1] [2]
  • Updated default core field and taxonomy field definitions to improve consistency and formatting. [1] [2]

Plugin Auto-Update Management

  • Introduced WP_Loupe_Auto_Update class to enable or disable automatic plugin updates via a settings toggle (defaults to enabled). This respects a constant-based opt-out (WP_LOUPE_DISABLE_AUTO_UPDATE) and user preferences.

REST API Enhancements

  • Improved REST API handler initialization and dependency loading, ensuring the REST API class is always loaded and initialized. Added namespaced compatibility shims to allow static analysis and testing outside of WordPress. [1] [2] [3]
  • Refactored REST route registration for better reliability and easier testing, including defensive checks for late initialization. [1] [2] [3]

Testing & Documentation

  • Expanded PHPUnit test result tracking to cover new settings, token service, and REST API behaviors.
  • Updated CHANGELOG.md with detailed notes on new features, migration strategies, fixes, and internal refactors.

These changes collectively improve the plugin's upgrade safety, maintainability, and extensibility, while providing clearer documentation and better test coverage.

- Updated `getPostTypeFields` method in `WpLoupeFieldManager` to gracefully handle REST fetch errors and fallback to a localized cache.
- Added error handling and basic validation for the response.

chore: Bump version to 0.5.5

- Updated version number in `package.json`, `readme.txt`, and main plugin file.

docs: Revise readme for clarity and conciseness

- Changed title and description for better clarity.
- Updated changelog with new features and fixes for version 0.5.5.

test: Add unit tests for schema manager and REST endpoints

- Created tests for `SchemaManager`, `REST PostTypeFields`, and `REST Search` to ensure functionality and correctness.
- Added tests for settings and token service behaviors.

feat: Implement auto-update functionality

- Added `WP_Loupe_Auto_Update` class to manage plugin auto-updates with user settings.
- Introduced settings toggle for enabling/disabling automatic updates.

feat: Migrate schema and ensure post_date field

- Created `WP_Loupe_Migration` class to handle schema migrations and ensure `post_date` field exists for all post types.
- Implemented logic for reindexing based on site size.

feat: Introduce token service for MCP operations

- Added `WP_Loupe_Token_Service` class to manage MCP tokens and rate limits.
- Implemented methods for creating, revoking, and saving rate limits for tokens.

test: Enhance tests for token service and settings

- Added tests for rate limits and token revocation to ensure proper functionality.
@soderlind soderlind merged commit ed481a3 into main Nov 10, 2025
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants