本文整理汇总了PHP中WP_CLI::set_url方法的典型用法代码示例。如果您正苦于以下问题:PHP WP_CLI::set_url方法的具体用法?PHP WP_CLI::set_url怎么用?PHP WP_CLI::set_url使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WP_CLI
的用法示例。
在下文中一共展示了WP_CLI::set_url方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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($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: _install
private function _install($assoc_args)
{
if (is_blog_installed()) {
return false;
}
require_once ABSPATH . 'wp-admin/includes/upgrade.php';
extract(wp_parse_args($assoc_args, array('title' => '', 'admin_user' => '', 'admin_email' => '', 'admin_password' => '')), EXTR_SKIP);
// Support prompting for the `--url=<url>`,
// which is normally a runtime argument
if (isset($assoc_args['url'])) {
$url_parts = WP_CLI::set_url($assoc_args['url']);
}
$public = true;
// @codingStandardsIgnoreStart
if (!is_email($admin_email)) {
WP_CLI::error("The '{$admin_email}' email address is invalid.");
}
$result = wp_install($title, $admin_user, $admin_email, $public, '', $admin_password);
if (is_wp_error($result)) {
WP_CLI::error('Installation failed (' . WP_CLI::error_to_string($result) . ').');
}
// @codingStandardsIgnoreEnd
// Confirm the uploads directory exists
$upload_dir = wp_upload_dir();
if (!empty($upload_dir['error'])) {
WP_CLI::warning($upload_dir['error']);
}
return true;
}
示例3: before_wp_load
public function before_wp_load()
{
$this->init_config();
$this->init_colorization();
$this->init_logger();
$this->check_root();
if (empty($this->arguments)) {
$this->arguments[] = 'help';
}
// Protect 'cli info' from most of the runtime
if ('cli' === $this->arguments[0] && !empty($this->arguments[1]) && 'info' === $this->arguments[1]) {
$this->_run_command();
exit;
}
// Load bundled commands early, so that they're forced to use the same
// APIs as non-bundled commands.
Utils\load_command($this->arguments[0]);
if (isset($this->config['require'])) {
foreach ($this->config['require'] as $path) {
if (!file_exists($path)) {
WP_CLI::error(sprintf("Required file '%s' doesn't exist", basename($path)));
}
Utils\load_file($path);
}
}
// Show synopsis if it's a composite command.
$r = $this->find_command_to_run($this->arguments);
if (is_array($r)) {
list($command) = $r;
if ($command->can_have_subcommands()) {
$command->show_usage();
exit;
}
}
// Handle --path parameter
self::set_wp_root($this->find_wp_root());
// First try at showing man page
if ('help' === $this->arguments[0] && !$this->wp_exists()) {
$this->_run_command();
}
// Handle --url parameter
$url = self::guess_url($this->config);
if ($url) {
\WP_CLI::set_url($url);
}
$this->do_early_invoke('before_wp_load');
$this->check_wp_version();
if ($this->cmd_starts_with(array('core', 'config'))) {
$this->_run_command();
exit;
}
if (!Utils\locate_wp_config()) {
WP_CLI::error("wp-config.php not found.\n" . "Either create one manually or use `wp core config`.");
}
if ($this->cmd_starts_with(array('db')) && !$this->cmd_starts_with(array('db', 'tables'))) {
eval($this->get_wp_config_code());
$this->_run_command();
exit;
}
if ($this->cmd_starts_with(array('core', 'is-installed'))) {
define('WP_INSTALLING', true);
}
if (count($this->arguments) >= 2 && $this->arguments[0] == 'core' && in_array($this->arguments[1], array('install', 'multisite-install'))) {
define('WP_INSTALLING', true);
// We really need a URL here
if (!isset($_SERVER['HTTP_HOST'])) {
$url = 'http://example.com';
\WP_CLI::set_url($url);
}
if ('multisite-install' == $this->arguments[1]) {
// need to fake some globals to skip the checks in wp-includes/ms-settings.php
$url_parts = Utils\parse_url($url);
self::fake_current_site_blog($url_parts);
if (!defined('COOKIEHASH')) {
define('COOKIEHASH', md5($url_parts['host']));
}
}
}
if ($this->cmd_starts_with(array('import'))) {
define('WP_LOAD_IMPORTERS', true);
define('WP_IMPORTING', true);
}
if ($this->cmd_starts_with(array('plugin'))) {
$GLOBALS['pagenow'] = 'plugins.php';
}
}
示例4: maybe_update_url_from_domain_constant
/**
* Called after wp-config.php is eval'd, to potentially reset `--url`
*/
private function maybe_update_url_from_domain_constant()
{
if (!empty($this->config['url']) || !empty($this->config['blog'])) {
return;
}
if (defined('DOMAIN_CURRENT_SITE')) {
$url = DOMAIN_CURRENT_SITE;
if (defined('PATH_CURRENT_SITE')) {
$url .= PATH_CURRENT_SITE;
}
\WP_CLI::set_url($url);
}
}
示例5: _install
private function _install($assoc_args)
{
if (is_blog_installed()) {
return false;
}
if (true === \WP_CLI\Utils\get_flag_value($assoc_args, 'skip-email') && !function_exists('wp_new_blog_notification')) {
function wp_new_blog_notification()
{
// Silence is golden
}
}
require_once ABSPATH . 'wp-admin/includes/upgrade.php';
extract(wp_parse_args($assoc_args, array('title' => '', 'admin_user' => '', 'admin_email' => '', 'admin_password' => '')), EXTR_SKIP);
// Support prompting for the `--url=<url>`,
// which is normally a runtime argument
if (isset($assoc_args['url'])) {
WP_CLI::set_url($assoc_args['url']);
}
$public = true;
// @codingStandardsIgnoreStart
if (!is_email($admin_email)) {
WP_CLI::error("The '{$admin_email}' email address is invalid.");
}
$result = wp_install($title, $admin_user, $admin_email, $public, '', $admin_password);
if (is_wp_error($result)) {
WP_CLI::error('Installation failed (' . WP_CLI::error_to_string($result) . ').');
}
// @codingStandardsIgnoreEnd
if (!empty($GLOBALS['wpdb']->last_error)) {
WP_CLI::error('Installation produced database errors, and may have partially or completely failed.');
}
// Confirm the uploads directory exists
$upload_dir = wp_upload_dir();
if (!empty($upload_dir['error'])) {
WP_CLI::warning($upload_dir['error']);
}
return true;
}
示例6: unset
if (!is_readable(WP_ROOT . 'wp-load.php')) {
WP_CLI::error('Either this is not a WordPress document root or you do not have permission to administer this site.');
exit;
}
// Handle --blog parameter
if (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'));
}
if (isset($blog)) {
WP_CLI::set_url($blog);
}
// Set installer flag before loading any WP files
if (count($arguments) >= 2 && $arguments[0] == 'core' && $arguments[1] == 'install') {
define('WP_INSTALLING', true);
}
// Load WordPress libs
require_once WP_ROOT . 'wp-load.php';
require_once ABSPATH . 'wp-admin/includes/admin.php';
// Load all internal commands
foreach (glob(WP_CLI_ROOT . '/commands/internals/*.php') as $filename) {
include $filename;
}
// Load all plugin commands
foreach (glob(WP_CLI_ROOT . '/commands/community/*.php') as $filename) {
include $filename;