Created
February 13, 2014 20:16
-
-
Save spacetrack/8982972 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class EvalFileWithArgs_Command extends WP_CLI_Command { | |
/** | |
* Load and execute a PHP file after loading WordPress. | |
* | |
* ## EXAMPLES | |
* | |
* wp eval-file-with-args my-code.php arg1 arg2 arg3 arg4 arg5 arg6 arg7 arg8 arg9 | |
* | |
* @synopsis <file> [<argA>] [<argB>] [<argC>] [<argD>] [<argE>] [<argF>] [<argG>] [<argH>] [<argI>] | |
*/ | |
public function __invoke( $args, $assoc_args ) { | |
if ( !file_exists( $args[0] ) ) { | |
WP_CLI::error( "'$args[0]' does not exist." ); | |
} else { | |
include( $args[0] ); | |
} | |
} | |
} | |
WP_CLI::add_command( 'eval-file-with-args', 'EvalFileWithArgs_Command' ); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment