当前位置: 首页>>代码示例>>PHP>>正文


PHP WP_CLI::error_to_string方法代码示例

本文整理汇总了PHP中WP_CLI::error_to_string方法的典型用法代码示例。如果您正苦于以下问题:PHP WP_CLI::error_to_string方法的具体用法?PHP WP_CLI::error_to_string怎么用?PHP WP_CLI::error_to_string使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在WP_CLI的用法示例。


在下文中一共展示了WP_CLI::error_to_string方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: update

 /**
  * Update WordPress.
  *
  * ## OPTIONS
  *
  * [<zip>]
  * : Path to zip file to use, instead of downloading from wordpress.org.
  *
  * [--version=<version>]
  * : Update to this version, instead of to the latest version.
  *
  * [--force]
  * : Update even when installed WP version is greater than the requested version.
  *
  * [--locale=<locale>]
  * : Select which language you want to download.
  *
  * ## EXAMPLES
  *
  *     wp core update
  *
  *     wp core update --version=3.8 ../latest.zip
  *
  *     wp core update --version=3.1 --force
  *
  * @alias upgrade
  */
 function update($args, $assoc_args)
 {
     global $wp_version;
     $update = $from_api = null;
     $upgrader = 'WP_CLI\\CoreUpgrader';
     if (!empty($args[0])) {
         $upgrader = 'WP_CLI\\NonDestructiveCoreUpgrader';
         $version = !empty($assoc_args['version']) ? $assoc_args['version'] : null;
         $update = (object) array('response' => 'upgrade', 'current' => $version, 'download' => $args[0], 'packages' => (object) array('partial' => null, 'new_bundled' => null, 'no_content' => null, 'full' => $args[0]), 'version' => $version, 'locale' => null);
     } else {
         if (empty($assoc_args['version'])) {
             wp_version_check();
             $from_api = get_site_transient('update_core');
             if (empty($from_api->updates)) {
                 $update = false;
             } else {
                 list($update) = $from_api->updates;
             }
         } else {
             if (version_compare($wp_version, $assoc_args['version'], '<') || isset($assoc_args['force'])) {
                 $version = $assoc_args['version'];
                 $locale = isset($assoc_args['locale']) ? $assoc_args['locale'] : get_locale();
                 $new_package = $this->get_download_url($version, $locale);
                 $update = (object) array('response' => 'upgrade', 'current' => $assoc_args['version'], 'download' => $new_package, 'packages' => (object) array('partial' => null, 'new_bundled' => null, 'no_content' => null, 'full' => $new_package), 'version' => $version, 'locale' => $locale);
             } else {
                 WP_CLI::success('WordPress is up to date.');
                 return;
             }
         }
     }
     require_once ABSPATH . 'wp-admin/includes/upgrade.php';
     if ($update->version) {
         WP_CLI::log("Updating to version {$update->version} ({$update->locale})...");
     } else {
         WP_CLI::log("Starting update...");
     }
     $GLOBALS['wp_cli_update_obj'] = $update;
     $result = Utils\get_upgrader($upgrader)->upgrade($update);
     unset($GLOBALS['wp_cli_update_obj']);
     if (is_wp_error($result)) {
         $msg = WP_CLI::error_to_string($result);
         if ('up_to_date' != $result->get_error_code()) {
             WP_CLI::error($msg);
         } else {
             WP_CLI::success($msg);
         }
     } else {
         WP_CLI::success('WordPress updated successfully.');
     }
 }
开发者ID:wturrell,项目名称:wp-cli,代码行数:77,代码来源:core.php

示例2: update

 /**
  * Update WordPress.
  *
  * ## OPTIONS
  *
  * [<zip>]
  * : Path to zip file to use, instead of downloading from wordpress.org.
  *
  * [--minor]
  * : Only perform updates for minor releases (e.g. update from WP 4.3 to 4.3.3 instead of 4.4.2).
  *
  * [--version=<version>]
  * : Update to a specific version, instead of to the latest version.
  *
  * [--force]
  * : Update even when installed WP version is greater than the requested version.
  *
  * [--locale=<locale>]
  * : Select which language you want to download.
  *
  * ## EXAMPLES
  *
  *     wp core update
  *
  *     wp core update --version=3.8 ../latest.zip
  *
  *     wp core update --version=3.1 --force
  *
  * @alias upgrade
  */
 function update($args, $assoc_args)
 {
     global $wp_version;
     $update = $from_api = null;
     $upgrader = 'WP_CLI\\CoreUpgrader';
     if (empty($args[0]) && empty($assoc_args['version']) && \WP_CLI\Utils\get_flag_value($assoc_args, 'minor')) {
         $updates = $this->get_updates(array('minor' => true));
         if (!empty($updates)) {
             $assoc_args['version'] = $updates[0]['version'];
         } else {
             WP_CLI::success('WordPress is at the latest minor release.');
             return;
         }
     }
     if (!empty($args[0])) {
         $upgrader = 'WP_CLI\\NonDestructiveCoreUpgrader';
         $version = \WP_CLI\Utils\get_flag_value($assoc_args, 'version');
         $update = (object) array('response' => 'upgrade', 'current' => $version, 'download' => $args[0], 'packages' => (object) array('partial' => null, 'new_bundled' => null, 'no_content' => null, 'full' => $args[0]), 'version' => $version, 'locale' => null);
     } else {
         if (empty($assoc_args['version'])) {
             wp_version_check();
             $from_api = get_site_transient('update_core');
             if (!empty($from_api->updates)) {
                 list($update) = $from_api->updates;
             }
         } else {
             if (\WP_CLI\Utils\wp_version_compare($assoc_args['version'], '<') || \WP_CLI\Utils\get_flag_value($assoc_args, 'force')) {
                 $version = $assoc_args['version'];
                 $locale = \WP_CLI\Utils\get_flag_value($assoc_args, 'locale', get_locale());
                 $new_package = $this->get_download_url($version, $locale);
                 $update = (object) array('response' => 'upgrade', 'current' => $assoc_args['version'], 'download' => $new_package, 'packages' => (object) array('partial' => null, 'new_bundled' => null, 'no_content' => null, 'full' => $new_package), 'version' => $version, 'locale' => $locale);
             }
         }
     }
     if (!empty($update) && ($update->version != $wp_version || \WP_CLI\Utils\get_flag_value($assoc_args, 'force'))) {
         require_once ABSPATH . 'wp-admin/includes/upgrade.php';
         if ($update->version) {
             WP_CLI::log("Updating to version {$update->version} ({$update->locale})...");
         } else {
             WP_CLI::log("Starting update...");
         }
         $from_version = $wp_version;
         $GLOBALS['wp_cli_update_obj'] = $update;
         $result = Utils\get_upgrader($upgrader)->upgrade($update);
         unset($GLOBALS['wp_cli_update_obj']);
         if (is_wp_error($result)) {
             $msg = WP_CLI::error_to_string($result);
             if ('up_to_date' != $result->get_error_code()) {
                 WP_CLI::error($msg);
             } else {
                 WP_CLI::success($msg);
             }
         } else {
             if (file_exists(ABSPATH . 'wp-includes/version.php')) {
                 include ABSPATH . 'wp-includes/version.php';
                 $to_version = $wp_version;
             }
             $locale = \WP_CLI\Utils\get_flag_value($assoc_args, 'locale', get_locale());
             $this->cleanup_extra_files($from_version, $to_version, $locale);
             WP_CLI::success('WordPress updated successfully.');
         }
     } else {
         WP_CLI::success('WordPress is up to date.');
     }
 }
开发者ID:anver,项目名称:wp-cli,代码行数:95,代码来源:core.php

示例3: update

 /**
  * Update WordPress.
  *
  * ## OPTIONS
  *
  * [<zip>]
  * : Path to zip file to use, instead of downloading from wordpress.org.
  *
  * [--version=<version>]
  * : Update to this version, instead of to the latest version.
  *
  * [--force]
  * : Will update even when current WP version < passed version. Use with
  * caution.
  *
  * ## EXAMPLES
  *
  *     wp core update
  *
  *     wp core update --version=3.4 ../latest.zip
  *
  *     wp core update --version=3.1 --force
  *
  * @alias upgrade
  */
 function update($args, $assoc_args)
 {
     global $wp_version;
     $update = $from_api = null;
     $upgrader = 'Core_Upgrader';
     if (empty($assoc_args['version'])) {
         wp_version_check();
         $from_api = get_site_transient('update_core');
         if (empty($from_api->updates)) {
             $update = false;
         } else {
             list($update) = $from_api->updates;
         }
     } else {
         if (version_compare($wp_version, $assoc_args['version'], '<') || isset($assoc_args['force'])) {
             $new_package = null;
             if (empty($args[0])) {
                 $new_package = 'https://wordpress.org/wordpress-' . $assoc_args['version'] . '.zip';
                 WP_CLI::log(sprintf('Downloading WordPress %s (%s)...', $assoc_args['version'], 'en_US'));
             } else {
                 $new_package = $args[0];
                 $upgrader = 'WP_CLI\\NonDestructiveCoreUpgrader';
             }
             $update = (object) array('response' => 'upgrade', 'current' => $assoc_args['version'], 'download' => $new_package, 'packages' => (object) array('partial' => null, 'new_bundled' => null, 'no_content' => null, 'full' => $new_package));
         } else {
             WP_CLI::success('WordPress is up to date.');
             return;
         }
     }
     require_once ABSPATH . 'wp-admin/includes/upgrade.php';
     $result = Utils\get_upgrader($upgrader)->upgrade($update);
     if (is_wp_error($result)) {
         $msg = WP_CLI::error_to_string($result);
         if ('up_to_date' != $result->get_error_code()) {
             WP_CLI::error($msg);
         } else {
             WP_CLI::success($msg);
         }
     } else {
         WP_CLI::success('WordPress updated successfully.');
     }
 }
开发者ID:nb,项目名称:wp-cli,代码行数:67,代码来源:core.php

示例4: list_events

 /**
  * List scheduled cron events.
  *
  * @since 1.2
  *
  * @alias list
  * @subcommand list-events
  * @synopsis [--format=<format>]
  */
 public function list_events($args, $assoc_args)
 {
     $defaults = array('format' => 'table');
     $values = wp_parse_args($assoc_args, $defaults);
     $events = $this->crontrol->get_cron_events();
     if (is_wp_error($events)) {
         WP_CLI::line(WP_CLI::error_to_string($events));
         die;
     }
     $events = array_map(array($this, '_map_event'), $events);
     $fields = array('hook', 'next_run', 'recurrence');
     \WP_CLI\Utils\format_items($values['format'], $events, $fields);
 }
开发者ID:kjih,项目名称:live,代码行数:22,代码来源:class-wp-cli.php


注:本文中的WP_CLI::error_to_string方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。