本文整理汇总了PHP中WP_CLI::errorToString方法的典型用法代码示例。如果您正苦于以下问题:PHP WP_CLI::errorToString方法的具体用法?PHP WP_CLI::errorToString怎么用?PHP WP_CLI::errorToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WP_CLI
的用法示例。
在下文中一共展示了WP_CLI::errorToString方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: error
function error($error)
{
if (!$error) {
return;
}
// TODO: show all errors, not just the first one
WP_CLI::warning(WP_CLI::errorToString($error));
}
示例2: update
/**
* Update the WordPress core
*
* @param array $args
*/
function update($args)
{
WP_CLI::line('Updating the WordPress core.');
if (!class_exists('Core_Upgrader')) {
require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
}
ob_start();
$upgrader = new Core_Upgrader(new CLI_Upgrader_Skin());
$result = $upgrader->upgrade($current);
$feedback = ob_get_clean();
// Borrowed verbatim from wp-admin/update-core.php
if (is_wp_error($result)) {
if ('up_to_date' != $result->get_error_code()) {
WP_CLI::error('Installation failed (' . WP_CLI::errorToString($result) . ').');
} else {
WP_CLI::success(WP_CLI::errorToString($result));
}
} else {
WP_CLI::success('WordPress upgraded successfully.');
}
}
示例3: install
/**
* Run wp_install. Assumes that wp-config.php is already in place.
*/
public function install($args, $assoc_args)
{
require_once ABSPATH . 'wp-admin/includes/upgrade.php';
if (is_blog_installed()) {
WP_CLI::error('WordPress is already installed.');
}
extract(wp_parse_args($assoc_args, array('site_url' => defined('WP_SITEURL') ? WP_SITEURL : '', 'site_title' => '', 'admin_name' => 'admin', 'admin_email' => '', 'admin_password' => '')), EXTR_SKIP);
$missing = false;
foreach (array('site_url', 'site_title', 'admin_email', 'admin_password') as $required_arg) {
if (empty(${$required_arg})) {
WP_CLI::warning("missing --{$required_arg} parameter");
$missing = true;
}
}
if ($site_url) {
WP_CLI::set_url($site_url);
}
if ($missing) {
exit(1);
}
$public = true;
$result = wp_install($site_title, $admin_name, $admin_email, $public, '', $admin_password);
if (is_wp_error($result)) {
WP_CLI::error('Installation failed (' . WP_CLI::errorToString($result) . ').');
} else {
WP_CLI::success('WordPress installed successfully.');
}
}
示例4: update
/**
* Update the WordPress core
*
* @param array $args
*/
function update($args)
{
wp_version_check();
$from_api = get_site_transient('update_core');
if (empty($from_api->updates)) {
$update = false;
} else {
list($update) = $from_api->updates;
}
require_once ABSPATH . 'wp-admin/includes/upgrade.php';
$result = WP_CLI::get_upgrader('Core_Upgrader')->upgrade($update);
if (is_wp_error($result)) {
$msg = WP_CLI::errorToString($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.');
}
}
示例5: error
function error($errors)
{
$this->feedback(WP_CLI::errorToString($errors));
}