/php/commands/eval-file.php
PHP | 22 lines | 13 code | 4 blank | 5 comment | 2 complexity | 99d9baee2ea5ef96209aa7908b993a69 MD5 | raw file
Possible License(s): MIT
- <?php
- class EvalFile_Command extends WP_CLI_Command {
- /**
- * Load and execute a PHP file after loading WordPress.
- *
- * @synopsis <path>
- */
- public function __invoke( $args, $assoc_args ) {
- foreach ( $args as $file ) {
- if ( !file_exists( $file ) ) {
- WP_CLI::error( "'$file' does not exist." );
- } else {
- include( $file );
- }
- }
- }
- }
- WP_CLI::add_command( 'eval-file', new EvalFile_Command );