PageRenderTime 70ms CodeModel.GetById 19ms RepoModel.GetById 1ms app.codeStats 0ms

/php/commands/eval-file.php

https://github.com/jmslbam/wp-cli
PHP | 22 lines | 13 code | 4 blank | 5 comment | 2 complexity | 99d9baee2ea5ef96209aa7908b993a69 MD5 | raw file
Possible License(s): MIT
  1. <?php
  2. class EvalFile_Command extends WP_CLI_Command {
  3. /**
  4. * Load and execute a PHP file after loading WordPress.
  5. *
  6. * @synopsis <path>
  7. */
  8. public function __invoke( $args, $assoc_args ) {
  9. foreach ( $args as $file ) {
  10. if ( !file_exists( $file ) ) {
  11. WP_CLI::error( "'$file' does not exist." );
  12. } else {
  13. include( $file );
  14. }
  15. }
  16. }
  17. }
  18. WP_CLI::add_command( 'eval-file', new EvalFile_Command );