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
// Hook already fired, start the shell immediately.
47
-
$this->start_shell( $assoc_args );
48
-
} else {
49
-
// Hook hasn't fired yet.
50
-
WP_CLI::error(
51
-
sprintf(
52
-
"The '%s' hook has not fired yet. The shell command runs after WordPress is loaded, so only hooks that have already been triggered can be used. Common hooks that are available include: init, plugins_loaded, wp_loaded.",
53
-
$hook
54
-
)
55
-
);
56
-
}
57
-
} else {
58
-
// No hook specified, start immediately.
43
+
// No hook specified, start immediately.
44
+
if ( ! $hook ) {
59
45
$this->start_shell( $assoc_args );
46
+
return;
60
47
}
48
+
49
+
// Check if the hook has already fired.
50
+
if ( did_action( $hook ) ) {
51
+
// Hook already fired, start the shell immediately.
52
+
$this->start_shell( $assoc_args );
53
+
return;
54
+
}
55
+
56
+
// Hook hasn't fired yet.
57
+
WP_CLI::error(
58
+
sprintf(
59
+
"The '%s' hook has not fired yet. " .
60
+
'The shell command runs after WordPress is loaded, so only hooks that have already been triggered can be used. ' .
61
+
'Common hooks that are available include: init, plugins_loaded, wp_loaded.',
0 commit comments