wp shell is a very useful tool that lets you run PHP statements and expressions interactively, from within a WordPress environment. It lets you use all the functions, classes and globals that you can use within WordPress.

Is there a similar tool that will let me run a PHP file?

1
1

Yes, there is! I didn’t find it at first, but wp cli offers a command called eval-file which does what you want:

$ echo '<?php echo is_wp_error("foo") ? 1 : 0;' > example.php
$ wp eval-file example.php
0

Tags:

Leave a Reply

Your email address will not be published. Required fields are marked *