WP_CLI::get_runner PHP Method

get_runner() public static method

public static get_runner ( )
    public static function get_runner()
    {
        static $runner;
        if (!$runner) {
            $runner = new WP_CLI\Runner();
        }
        return $runner;
    }

Usage Example

Example #1
0
 /**
  * Execute arbitrary PHP code.
  *
  * ## OPTIONS
  *
  * <php-code>
  * : The code to execute, as a string.
  *
  * [--skip-wordpress]
  * : Execute code without loading WordPress.
  *
  * @when before_wp_load
  *
  * ## EXAMPLES
  *
  *     $ wp eval 'echo WP_CONTENT_DIR;'
  *     /var/www/wordpress/wp-content
  *
  *     $ wp eval 'echo rand();' --skip-wordpress
  *     479620423
  */
 public function __invoke($args, $assoc_args)
 {
     if (null === \WP_CLI\Utils\get_flag_value($assoc_args, 'skip-wordpress')) {
         WP_CLI::get_runner()->load_wordpress();
     }
     eval($args[0]);
 }
All Usage Examples Of WP_CLI::get_runner