-
Notifications
You must be signed in to change notification settings - Fork 14
Add --hook flag to defer eval execution to WordPress lifecycle hooks #84
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
base: main
Are you sure you want to change the base?
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
--hook=<hook> flag to eval and shell commandsThere 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 adds a --hook flag to the eval and eval-file commands, allowing users to defer code execution until a specific WordPress lifecycle hook fires. Previously, code always executed immediately after WordPress loaded, which prevented users from running code that depends on plugins or themes being fully initialized.
Changes:
- Adds
--hook=<hook>parameter to control execution timing within the WordPress lifecycle - Validates that
--hookcannot be used with--skip-wordpress - Maintains backward compatibility - without
--hook, behavior is unchanged
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/Eval_Command.php | Implements hook registration logic, parameter validation, and conditional execution for the eval command |
| src/EvalFile_Command.php | Implements hook registration logic, parameter validation, and conditional execution for the eval-file command |
| features/eval.feature | Adds comprehensive test coverage for hook functionality, error conditions, and edge cases including positional arguments |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Adds
--hook=<hook>parameter toevalandeval-filecommands to control execution timing within the WordPress lifecycle. Previously, code always executed immediately after WordPress loaded. Some use cases require deferring execution until specific preconditions are met (e.g., plugins loaded, theme initialized).Implementation
--hookspecified--hook, behavior unchanged (immediate execution)--hookincompatible with--skip-wordpressUsage
Changes
src/Eval_Command.php: Hook registration logic, parameter validationsrc/EvalFile_Command.php: Hook registration logic, parameter validationfeatures/eval.feature: Test coverage for hook functionality and edge casesOriginal prompt
--hook=<hook>flag toevalandshellto choose timing ideas#146✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.