本文整理汇总了PHP中WP_CLI::set_url_params方法的典型用法代码示例。如果您正苦于以下问题:PHP WP_CLI::set_url_params方法的具体用法?PHP WP_CLI::set_url_params怎么用?PHP WP_CLI::set_url_params使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WP_CLI
的用法示例。
在下文中一共展示了WP_CLI::set_url_params方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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_params($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.');
}
}
示例2: _set_url
static function _set_url(&$assoc_args)
{
if (isset($assoc_args['url'])) {
$blog = $assoc_args['url'];
unset($assoc_args['url']);
} elseif (isset($assoc_args['blog'])) {
$blog = $assoc_args['blog'];
unset($assoc_args['blog']);
if (true === $blog) {
WP_CLI::line('usage: wp --blog=example.com');
}
} elseif (is_readable(WP_ROOT . 'wp-cli-blog')) {
$blog = trim(file_get_contents(WP_ROOT . 'wp-cli-blog'));
} else {
// Try to find the blog parameter in the wp-config file
if (file_exists(WP_ROOT . '/wp-config.php')) {
$wp_config_file = file_get_contents(WP_ROOT . '/wp-config.php');
$hit = array();
if (preg_match_all("#.*define\\s*\\(\\s*(['|\"]{1})(.+)(['|\"]{1})\\s*,\\s*(['|\"]{1})(.+)(['|\"]{1})\\s*\\)\\s*;#iU", $wp_config_file, $matches)) {
foreach ($matches[2] as $def_key => $def_name) {
if ('DOMAIN_CURRENT_SITE' == $def_name) {
$hit['domain'] = $matches[5][$def_key];
}
if ('PATH_CURRENT_SITE' == $def_name) {
$hit['path'] = $matches[5][$def_key];
}
}
}
if (!empty($hit) && isset($hit['domain'])) {
$blog = $hit['domain'];
}
if (!empty($hit) && isset($hit['path'])) {
$blog .= $hit['path'];
}
}
}
if (isset($blog)) {
WP_CLI::set_url_params($blog);
}
}