當前位置: 首頁>>代碼示例>>PHP>>正文


PHP WP_CLI::halt方法代碼示例

本文整理匯總了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);
 }
開發者ID:wp-cli,項目名稱:wp-cli,代碼行數:37,代碼來源:option.php

示例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);
         }
     }
 }
開發者ID:wp-cli,項目名稱:wp-cli,代碼行數:40,代碼來源:core.php

示例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);
     }
 }
開發者ID:wp-cli,項目名稱:wp-cli,代碼行數:27,代碼來源:plugin.php

示例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);
     }
 }
開發者ID:wp-cli,項目名稱:wp-cli,代碼行數:15,代碼來源:export.php

示例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);
     }
 }
開發者ID:wp-cli,項目名稱:wp-cli,代碼行數:28,代碼來源:theme.php


注:本文中的WP_CLI::halt方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。