本文整理汇总了PHP中WP_CLI::halt方法的典型用法代码示例。如果您正苦于以下问题:PHP WP_CLI::halt方法的具体用法?PHP WP_CLI::halt怎么用?PHP WP_CLI::halt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WP_CLI
的用法示例。
在下文中一共展示了WP_CLI::halt方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get
/**
* 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);
}
示例2: is_installed
/**
* Check if WordPress is installed.
*
* Determines whether WordPress is installed by checking if the standard
* database tables are installed. Doesn't produce output; uses exit codes
* to communicate whether WordPress is installed.
*
* [--network]
* : Check if this is a multisite install.
*
* ## EXAMPLES
*
* # Check whether WordPress is installed; exit status 0 if installed, otherwise 1
* $ wp core is-installed
* $ echo $?
* 1
*
* # Bash script for checking whether WordPress is installed or not
* if ! $(wp core is-installed); then
* wp core install
* fi
*
* @subcommand is-installed
*/
public function is_installed($_, $assoc_args)
{
if (\WP_CLI\Utils\get_flag_value($assoc_args, 'network')) {
if (is_blog_installed() && is_multisite()) {
WP_CLI::halt(0);
} else {
WP_CLI::halt(1);
}
} else {
if (is_blog_installed()) {
WP_CLI::halt(0);
} else {
WP_CLI::halt(1);
}
}
}
示例3: is_installed
/**
* Check if the plugin is installed.
*
* Returns exit code 0 when installed, 1 when uninstalled.
*
* ## OPTIONS
*
* <plugin>
* : The plugin to check.
*
* ## EXAMPLES
*
* # Check whether plugin is installed; exit status 0 if installed, otherwise 1
* $ wp plugin is-installed hello-dolly
* $ echo $?
* 1
*
* @subcommand is-installed
*/
public function is_installed($args, $assoc_args = array())
{
if ($this->fetcher->get($args[0])) {
WP_CLI::halt(0);
} else {
WP_CLI::halt(1);
}
}
示例4: validate_args
private function validate_args($args)
{
$has_errors = false;
foreach ($args as $key => $value) {
if (is_callable(array($this, 'check_' . $key))) {
$result = call_user_func(array($this, 'check_' . $key), $value);
if (false === $result) {
$has_errors = true;
}
}
}
if ($has_errors) {
WP_CLI::halt(1);
}
}
示例5: is_installed
/**
* Check if the theme is installed.
*
* Returns exit code 0 when installed, 1 when uninstalled.
*
* ## OPTIONS
*
* <theme>
* : The theme to check.
*
* ## EXAMPLES
*
* # Check whether theme is installed; exit status 0 if installed, otherwise 1
* $ wp theme is-installed hello-dolly
* $ echo $?
* 1
*
* @subcommand is-installed
*/
public function is_installed($args, $assoc_args = array())
{
$theme = wp_get_theme($args[0]);
if ($theme->exists()) {
WP_CLI::halt(0);
} else {
WP_CLI::halt(1);
}
}