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


PHP WP_CLI::set_url方法代码示例

本文整理汇总了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.');
     }
 }
开发者ID:noahmuller,项目名称:wp-cli,代码行数:31,代码来源:core.php

示例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;
 }
开发者ID:wturrell,项目名称:wp-cli,代码行数:29,代码来源:core.php

示例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';
     }
 }
开发者ID:Jazz-Man,项目名称:wp-cli,代码行数:86,代码来源:Runner.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);
     }
 }
开发者ID:wesm87,项目名称:wp-cli,代码行数:16,代码来源:Runner.php

示例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;
 }
开发者ID:Faisalawanisee,项目名称:wp-cli,代码行数:38,代码来源:core.php

示例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;
开发者ID:noahmuller,项目名称:wp-cli,代码行数:31,代码来源:wp-cli.php


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