File tree Expand file tree Collapse file tree 2 files changed +12
-15
lines changed
Expand file tree Collapse file tree 2 files changed +12
-15
lines changed Original file line number Diff line number Diff line change @@ -58,6 +58,10 @@ public function __invoke( $args, $assoc_args ) {
5858 WP_CLI ::error ( '"-" and "--use-include" parameters cannot be used at the same time ' );
5959 }
6060
61+ $ execute_closure = function () use ( $ file , $ args , $ use_include ) {
62+ self ::execute_eval ( $ file , $ args , $ use_include );
63+ };
64+
6165 $ hook = Utils \get_flag_value ( $ assoc_args , 'hook ' );
6266 $ skip_wordpress = Utils \get_flag_value ( $ assoc_args , 'skip-wordpress ' );
6367
@@ -66,20 +70,15 @@ public function __invoke( $args, $assoc_args ) {
6670 }
6771
6872 if ( $ hook ) {
69- WP_CLI ::add_wp_hook (
70- $ hook ,
71- function () use ( $ file , $ args , $ use_include ) {
72- self ::execute_eval ( $ file , $ args , $ use_include );
73- }
74- );
73+ WP_CLI ::add_wp_hook ( $ hook , $ execute_closure );
7574 }
7675
7776 if ( null === $ skip_wordpress ) {
7877 WP_CLI ::get_runner ()->load_wordpress ();
7978 }
8079
8180 if ( ! $ hook ) {
82- self :: execute_eval ( $ file , $ args , $ use_include );
81+ $ execute_closure ( );
8382 }
8483 }
8584
Original file line number Diff line number Diff line change @@ -39,6 +39,10 @@ class Eval_Command extends WP_CLI_Command {
3939 */
4040 public function __invoke ( $ args , $ assoc_args ) {
4141
42+ $ execute_closure = function () use ( $ args ) {
43+ eval ( $ args [0 ] );
44+ };
45+
4246 $ hook = Utils \get_flag_value ( $ assoc_args , 'hook ' );
4347 $ skip_wordpress = Utils \get_flag_value ( $ assoc_args , 'skip-wordpress ' );
4448
@@ -47,21 +51,15 @@ public function __invoke( $args, $assoc_args ) {
4751 }
4852
4953 if ( $ hook ) {
50- $ code = $ args [0 ];
51- WP_CLI ::add_wp_hook (
52- $ hook ,
53- function () use ( $ code ) {
54- eval ( $ code );
55- }
56- );
54+ WP_CLI ::add_wp_hook ( $ hook , $ execute_closure );
5755 }
5856
5957 if ( null === $ skip_wordpress ) {
6058 WP_CLI ::get_runner ()->load_wordpress ();
6159 }
6260
6361 if ( ! $ hook ) {
64- eval ( $ args [ 0 ] );
62+ $ execute_closure ( );
6563 }
6664 }
6765}
You can’t perform that action at this time.
0 commit comments