示例#1
0
 /**
  * @inheritdoc
  */
 public function run(ArrayAccess $paths)
 {
     $n = count(explode('/', str_replace('\\', '/', $paths['wp']))) - 1;
     $rootPathRel = str_repeat('dirname(', $n) . '__DIR__' . str_repeat(')', $n);
     $this->vars = array('BOOTSTRAP_PATH' => $rootPathRel . ".'/{$paths['wp']}/wp-blog-header.php'");
     $build = $this->builder->build($paths, 'index.example', $this->vars);
     if (!$this->builder->save($build, dirname($this->targetPath($paths)), 'index.php')) {
         $this->error = 'Error on create index.php.';
         return self::ERROR;
     }
     return self::SUCCESS;
 }
示例#2
0
 /**
  * Build .gitignore content based on settings.
  *
  * @param  \ArrayAccess $paths
  * @return int
  */
 private function create(ArrayAccess $paths)
 {
     $toDo = is_array($this->config) ? $this->config : self::$default;
     $filePaths = array_unique(array_filter(array_merge(array($this->env, $paths['wp-parent'] . '/wp-config.php'), $toDo['custom'], $this->paths($toDo, $paths))));
     $content = '### WP Starter' . PHP_EOL . implode(PHP_EOL, $filePaths) . PHP_EOL;
     if ($toDo['common']) {
         $common = trim($this->builder->build($paths, '.gitignore.example'));
         $content = $common ? $content . PHP_EOL . PHP_EOL . $common : $content;
     }
     if (!$this->builder->save($content, $paths['root'], '.gitignore')) {
         $this->error = 'WP Starter was not able to create .gitignore file.';
         return self::ERROR;
     }
     return self::SUCCESS;
 }
示例#3
0
 /**
  * @inheritdoc
  */
 public function run(ArrayAccess $paths)
 {
     $register = $this->config['register-theme-folder'];
     if ($register === 'ask') {
         $register = $this->askForRegister();
     }
     $n = count(explode('/', str_replace('\\', '/', $paths['wp']))) - 1;
     $rootPathRel = str_repeat('dirname(', $n) . '__DIR__' . str_repeat(')', $n);
     $relUrl = function ($path) use($paths) {
         return $paths['wp-parent'] ? trim(substr($path, strlen($paths['wp-parent'])), '\\/') : trim($path, '\\/');
     };
     $vars = array_merge(array('VENDOR_PATH' => $rootPathRel . ".'/{$paths['vendor']}'", 'ENV_REL_PATH' => $rootPathRel, 'WP_INSTALL_PATH' => $rootPathRel . ".'/{$paths['wp']}'", 'WP_CONTENT_PATH' => $rootPathRel . ".'/{$paths['wp-content']}'", 'WP_SITEURL' => $relUrl($paths['wp']), 'WP_CONTENT_URL' => $relUrl($paths['wp-content']), 'REGISTER_THEME_DIR' => $register ? 'true' : 'false', 'ENV_FILE_NAME' => $this->config['env-file']), $this->salter->keys());
     $build = $this->builder->build($paths, 'wp-config.example', $vars);
     if (!$this->builder->save($build, dirname($this->targetPath($paths)), 'wp-config.php')) {
         $this->error = 'Error on create wp-config.php.';
         return self::ERROR;
     }
     return self::SUCCESS;
 }