Ejemplo n.º 1
0
 /**
  * Get the path to the project-specific configuration
  * YAML file.
  * wp-cli.local.yml takes priority over wp-cli.yml.
  *
  * @return string|false
  */
 private function get_project_config_path()
 {
     $config_files = array('wp-cli.local.yml', 'wp-cli.yml');
     // Stop looking upward when we find we have emerged from a subdirectory
     // install into a parent install
     $project_config_path = Utils\find_file_upward($config_files, getcwd(), function ($dir) {
         static $wp_load_count = 0;
         $wp_load_path = $dir . DIRECTORY_SEPARATOR . 'wp-load.php';
         if (file_exists($wp_load_path)) {
             $wp_load_count += 1;
         }
         return $wp_load_count > 1;
     });
     if (!empty($project_config_path)) {
         $this->_project_config_path_debug = 'Using project config: ' . $project_config_path;
     } else {
         $this->_project_config_path_debug = 'No project config found';
     }
     return $project_config_path;
 }
Ejemplo n.º 2
0
 /**
  * Get the path to the project-specific configuration
  * YAML file.
  * wp-cli.local.yml takes priority over wp-cli.yml.
  *
  * @return string|false
  */
 private static function get_project_config_path()
 {
     $config_files = array('wp-cli.local.yml', 'wp-cli.yml');
     // Stop looking upward when we find we have emerged from a subdirectory
     // install into a parent install
     return Utils\find_file_upward($config_files, getcwd(), function ($dir) {
         static $wp_load_count = 0;
         $wp_load_path = $dir . DIRECTORY_SEPARATOR . 'wp-load.php';
         if (file_exists($wp_load_path)) {
             $wp_load_count += 1;
         }
         return $wp_load_count > 1;
     });
 }
Ejemplo n.º 3
0
Archivo: Runner.php Proyecto: nb/wp-cli
 public function before_wp_load()
 {
     $this->init_config();
     $this->init_colorization();
     $this->init_logger();
     if (empty($this->arguments)) {
         $this->arguments[] = 'help';
     }
     // 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) {
             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->has_subcommands()) {
             $command->show_usage();
             exit;
         }
     }
     // Handle --path parameter
     if (!isset($this->config['path'])) {
         if ($this->cmd_starts_with(array('core', 'download'))) {
             $this->config['path'] = getcwd();
         } else {
             $this->config['path'] = dirname(Utils\find_file_upward('wp-load.php'));
         }
     }
     self::set_wp_root($this->config);
     // First try at showing man page
     if ('help' === $this->arguments[0] && (isset($this->arguments[1]) || !$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'))) {
         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';
     }
 }