/** * @inheritdoc */ public function run(ArrayAccess $paths) { $dest = $this->targetPath($paths); if (!$this->overwrite->should($dest)) { $this->io->comment(" - {$this->name} skipped."); return; } $this->actionSource[0] === 'download' ? $this->download($this->actionSource[1], $dest) : $this->copy($this->actionSource[1], $dest, $paths); }
/** * @inheritdoc */ public function question(Config $config, IO $io) { if ($config['move-content'] !== 'ask') { return true; } $to = str_replace('\\', '/', $this->paths['wp-content']); $full = str_replace('\\', '/', $this->paths['root']) . '/' . ltrim($to, '/'); $lines = array('Do you want to move default plugins and themes from', 'WordPress package wp-content dir to content folder:', '"' . $full . '"'); return $io->ask($lines, true); }
/** * Print to console final message. * * @return int */ private function finalMessage() { if ($this->errors > 0) { $this->io->block($this->error(), 'red', true); return self::ERROR; } $this->io->block($this->success(), 'green', false); return self::SUCCESS; }
/** * Download .gitignore from a given url. * * @param \ArrayAccess $paths * @return int */ private function download(ArrayAccess $paths) { if (!UrlDownloader::checkSoftware()) { $this->io->comment('WP Starter needs cUrl installed to download files from url.'); return $this->create($paths); } $remote = new UrlDownloader($this->config); if ($remote->save($this->targetPath($paths))) { return self::SUCCESS; } $this->error = 'Error on downloading and saving .gitignore. ' . $remote->error(); return self::ERROR; }
/** * Download a remote .env.example in root folder. * * @param string $url * @param string $dest * @param \ArrayAccess $paths * @return int */ private function download($url, $dest, ArrayAccess $paths) { if (!UrlDownloader::checkSoftware()) { $this->io->comment('WP Starter needs cUrl installed to download files from url.'); return $this->copy($paths, $dest); } $remote = new UrlDownloader($url); if (!$remote->save($dest)) { $this->error = 'Error on downloading and save .env.example: ' . $remote->error() . '.'; return self::ERROR; } return self::SUCCESS; }
/** * Asks to user what to do in case of unknown dropins. * Question is different based on situations. * * @param string $name * @param int $question * @return bool */ private function ask($name, $question = 0) { switch ($question) { case 2: $lines = array("{$name} is not a core supported locale for WP " . $this->config['wp-version'], "Do you want to proceed with {$name}.php anyway?"); break; case 1: $lines = array('WP Starter failed to get languages from wordpress.org API,', "so it isn't possible to verify that {$name} is a supported locale.", "Do you want to proceed with {$name}.php anyway?"); break; case 0: default: $lines = array("{$name} seems not a valid dropin file.", "Do you want to proceed with it anyway?"); break; } return $this->io->ask($lines, false); }
/** * @inheritdoc */ public function postProcess(IO $io) { if (!$this->themeDir) { $lines = array('Default theme folder:', '"' . $this->paths['wp-content'] . '/themes" does not exist.', 'The site may be unusable until you create it (even empty).'); $io->block($lines, 'red', true); } }
/** * @return bool */ private function askForRegister() { $lines = array('Do you want to register WordPress package wp-content folder', 'as additional theme folder for your project?'); return $this->io->ask($lines, true); }
/** * @param \WCM\WPStarter\Setup\StepperInterface $stepper * @param \WCM\WPStarter\Setup\Config $config * @param \ArrayObject $paths * @param \WCM\WPStarter\Setup\IO $io * @return bool */ private function stepperAllowed(StepperInterface $stepper, Config $config, ArrayObject $paths, IO $io) { if (!$stepper->allowed($config, $paths)) { $lines = array('WP Starter installation CANCELED.', 'wp-config.php was found in root folder and your overwrite settings', 'do not allow to proceed.'); $io->block($lines, 'yellow'); return false; } return true; }