WP_CLI::halt PHP Method

halt() public static method

Permits script execution to be overloaded by WP_CLI::runcommand()
public static halt ( integer $return_code )
$return_code integer
    public static function halt($return_code)
    {
        if (self::$capture_exit) {
            throw new ExitException(null, $return_code);
        }
        exit($return_code);
    }

Usage Example

Esempio n. 1
0
 /**
  * Get the value for an option.
  *
  * ## OPTIONS
  *
  * <key>
  * : Key for the option.
  *
  * [--format=<format>]
  * : Get value in a particular format.
  * ---
  * default: var_export
  * options:
  *   - var_export
  *   - json
  *   - yaml
  * ---
  *
  * ## EXAMPLES
  *
  *     # Get option.
  *     $ wp option get home
  *     http://example.com
  *
  *     # Get option in JSON format.
  *     $ wp option get active_plugins --format=json
  *     {"0":"dynamically-dynamic-sidebar\/dynamically-dynamic-sidebar.php","1":"monster-widget\/monster-widget.php","2":"show-current-template\/show-current-template.php","3":"theme-check\/theme-check.php","5":"wordpress-importer\/wordpress-importer.php"}
  */
 public function get($args, $assoc_args)
 {
     list($key) = $args;
     $value = get_option($key);
     if (false === $value) {
         WP_CLI::halt(1);
     }
     WP_CLI::print_value($value, $assoc_args);
 }
All Usage Examples Of WP_CLI::halt