You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Docs say "before_wp_load" but everything is loaded already? #78
This command runs on the before_wp_load hook, just before the WP load process begins
In my layman understanding I'd assumed that this means that hooks like "init", "plugins_loaded",... haven't run yet when the code in the "eval-file" is executed.
Turns out this is wrong. All plugins and the theme have been loaded already, "plugins_loaded" hook is done,...
Basically everything except any CLI things hooked to after_wp_load are done (to also have that available, one would have to pipe to wp shell)
Is this expected or a bug?
If this is expected - would it be possible to change the description to make clear what exactly is meant with "just before the WP load process begins"?
Describe how other contributors can replicate this bug
wp eval-file /foo.php --use-include
where foo.php contains:
<?php
var_dump( did_action( 'plugins_loaded' ) );
// WooCommerce is installed in the environment and active
var_dump( function_exists( 'WC' ) );
Describe what you would expect as the correct outcome
The current behavior is ok and changing it would probably break tons of people's scripts/code. A clarification in the docs is needed though?
While the eval-file command is indeed hooked to before_wp_load, it manually loads WordPress before your own file, unless --skip-wordpress is provided. See:
Activity
swissspidy commentedon Feb 18, 2025
While the
eval-filecommand is indeed hooked tobefore_wp_load, it manually loads WordPress before your own file, unless--skip-wordpressis provided. See:eval-command/src/EvalFile_Command.php
Lines 55 to 59 in 20ec428
I guess we could clarify the documentation a little bit. PRs welcome :)
As for your other question, yes,
--requireloads your file very early.