-
Notifications
You must be signed in to change notification settings - Fork 2
feat: Initial scaffold of Toolbar #432
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Integrate toolbar demo with real WordPress instance using wp-env: - Add CORS headers via mu-plugin for localhost:3000 - Fetch real WordPress user via REST API - Fetch posts using WPGraphQL - Update demo UI with real data workflow - Document WordPress integration in README Updates: - Use query parameter format for REST API (/?rest_route=) - Use query parameter format for GraphQL (/?graphql) - Add lifecycle script for permalink setup - Update demo instructions for real WordPress workflow
…base styles for full developer control
…tion Switch vanilla example from hardcoded configs to auto-generated approach. Files like mu-plugin.php, .htaccess, and .wp-env.json are now generated from centralized templates by the setup-env.js script. - Add setup-env.js script that generates configs from templates - Remove mu-plugin.php, .htaccess, .wp-env.json from version control - Update .gitignore to exclude auto-generated example files
Add comprehensive Next.js App Router example demonstrating the toolbar with real WordPress integration. - Complete Next.js example with App Router - Hash-based port calculation for deterministic ports - Template-based configuration (mu-plugin, .htaccess, .wp-env.json) - One-command startup with concurrently - Real WordPress data integration (no mocks) - WPGraphQL for post fetching - Responsive toolbar with real user data
Enhance toolbar with configurable options and example improvements: Toolbar Package: - Add position config (top/bottom) with CSS positioning - Add theme config with custom CSS variables and className - Add getConfig/setConfig methods for runtime updates - Improve CSS with position-aware dropdown menus Vanilla Example: - Use hash-based port calculation from setup-env.js - Load ports from generated .env file in Vite config - Update scripts to use template-based configuration - Add pnpm workspace configuration - Remove hardcoded mu-plugin.php (now generated)
Introduces three reusable, single-responsibility plugins for headless WordPress development: - hwp-cors-local: Enables CORS headers for local development environments - hwp-frontend-links: Adds "View on Frontend" links to WordPress admin interface - hwp-wp-env-helpers: Fixes wp-env REST API routing quirks Each plugin is independently configurable via HEADLESS_FRONTEND_URL constant and can be used standalone or in combination based on project needs.
… plugins Updates toolbar demo examples to use production-ready configuration: - WP_HOME points to WordPress instance (not frontend) - HEADLESS_FRONTEND_URL configured separately for frontend application - Replaces mu-plugin template approach with modular plugin references - Updates PHP version to 8.3 - Removes mu-plugin mapping in favor of standard plugin loading This allows WordPress to remain fully functional while supporting headless architecture, and enables composable plugin usage across different projects.
wp-env cannot resolve relative plugin paths from subdirectories. Changed setup-env.js to generate absolute paths using path.resolve() and path.join(), ensuring plugins load correctly in both vanilla and Next.js examples. Also added comprehensive implementation breakdown documentation.
Updated example:start scripts in both toolbar demos to use concurrently properly. WordPress and frontend now start together using concurrently, with a 5 second delay on frontend to ensure WordPress completes startup. Changes: - Separated wp-env setup (npm install) into wp:ensure script - Modified wp:start to only run wp-env start (no blocking npm install) - Used concurrently to run both services in parallel - Added sleep 5 before frontend start to allow wp-env initialization
… DRY - Remove mu-plugin.php template and generation code - Use relative paths for plugin references (portable across machines) - Simplify npm scripts (inline npm install, remove wp:ensure) - Add .gitignore files to exclude generated files - Align both toolbar examples with consistent configuration
Refactored plugin to support both single and multiple frontend configurations via HEADLESS_FRONTEND_URL or HWP_FRONTEND_LINKS. Admin bar and post row actions now display a 'View in [Label]' link for each configured frontend, improving flexibility for sites with multiple environments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR introduces a comprehensive headless WordPress toolkit with a modular plugin architecture and production-ready toolbar package. It transforms the previous template-based approach into a maintainable, reusable system with dynamic configuration and comprehensive documentation.
- Creates three single-responsibility WordPress plugins for CORS, frontend links, and wp-env helpers
- Introduces the @wpengine/hwp-toolbar package with framework-agnostic design and React hooks
- Updates examples to use the new plugin architecture with dynamic port calculation
- Provides complete documentation and production-ready configuration patterns
Reviewed Changes
Copilot reviewed 44 out of 47 changed files in this pull request and generated 3 comments.
Show a summary per file
File | Description |
---|---|
packages/toolbar/* | Core toolbar package with TypeScript, React hooks, and vanilla renderer |
plugins/* | Three modular WordPress plugins for headless development |
examples//toolbar-demo/ | Updated demo applications using new architecture |
scripts/get-ports.js | Dynamic port calculation system for multi-example setup |
IMPLEMENTATION_BREAKDOWN.md | Comprehensive implementation documentation |
Comments suppressed due to low confidence (1)
plugins/hwp-wp-env-helpers/hwp-wp-env-helpers.php:1
- Direct $_SERVER access should be validated. Consider using
sanitize_text_field()
or checking if the key exists before accessing.
<?php
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
@ahuseyn I'm working on resolving these last build issues but i'll mark it ready for review now :) |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
📦 Plugin Artifacts Ready!Download from GitHub Actions run Available plugins:
See the "Artifacts" section at the bottom of the Actions run page |
Eliminate TypeScript compilation requirement and convert to vanilla JS following the CLI package pattern. Changes: - Convert src/index.ts → src/core/Toolbar.js (with JSDoc types) - Convert src/react.ts → src/react.js (with JSDoc types) - Create modular structure: src/core/Toolbar.js and src/core/VanillaRenderer.js - Update package.json to point to src/ instead of dist/ - Remove TypeScript configuration (tsconfig.json) - Remove build scripts and TypeScript dependencies - Fix Next.js example dev.sh to use npx Benefits: ✅ No build step required ✅ Direct source consumption ✅ Faster development (no compilation watch) ✅ Simpler package structure ✅ JSDoc provides IDE autocomplete/intellisense ✅ Same pattern as CLI package
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Copilot reviewed 56 out of 59 changed files in this pull request and generated 6 comments.
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
examples/next/toolbar-demo/example-app/app/components/Toolbar.tsx
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Copilot reviewed 56 out of 59 changed files in this pull request and generated 9 comments.
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
examples/next/toolbar-demo/example-app/app/components/Toolbar.tsx
Outdated
Show resolved
Hide resolved
@josephfusco awesome job. |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Enhance error messages in Next.js toolbar example to provide specific, actionable guidance for common WordPress connection failures. Changes: - Add comprehensive status code handling (401, 403, 404, 500+) in wordpress.ts - Parse WordPress error response JSON for detailed error messages - Detect "No route was found" errors and suggest hwp-wp-env-helpers plugin - Provide specific troubleshooting steps for CORS, network, and server errors - Update page.tsx to display detailed error messages instead of generic text Error messages now include: - Multiple possible causes for each error type - Specific commands to resolve issues (npx wp-env start, etc.) - References to required plugins (hwp-cors-local, hwp-wp-env-helpers) - WordPress log checking instructions for server errors
Removed custom setup and dev scripts in favor of simplified npm scripts for app and WordPress management. Updated .wp-env.json for new PHP version, plugin paths, and config values. Improved README with clearer setup instructions, troubleshooting, and port configuration. Adjusted Vite config for default port fallback and cleaned up package.json scripts.
Simplifies environment setup by removing custom scripts and shell files, updating package.json scripts, and standardizing port usage to 8888 for WordPress. The README is rewritten for clarity, providing step-by-step instructions and improved documentation. Updates dependencies and example environment files to match the new configuration.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Relocated Next.js and Vanilla JS toolbar demo examples and related plugins from the root examples/ and plugins/ directories into packages/toolbar/examples/. Updated documentation, configuration, and paths to reflect the new structure. Removed IMPLEMENTATION_BREAKDOWN.md as part of project cleanup.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work @josephfusco! Tested examples in their new directories and working.
Zero-build toolbar implementation for headless WordPress applications.
Package Structure
@wpengine/hwp-toolbar
WordPress Plugins
hwp-cors-local
– Local development CORS headershwp-frontend-links
– Admin bar frontend routinghwp-wp-env-helpers
– Docker environment REST API patchesImplementation
Vanilla
React
Technical Details
Running Examples
Fixes #427