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


PHP Utils\locate_wp_config函数代码示例

本文整理汇总了PHP中WP_CLI\Utils\locate_wp_config函数的典型用法代码示例。如果您正苦于以下问题:PHP locate_wp_config函数的具体用法?PHP locate_wp_config怎么用?PHP locate_wp_config使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了locate_wp_config函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: finishRestore

 /**
  * Finishes clone operation
  *
  * @subcommand finish-restore-site
  *
  * @when before_wp_load
  *
  */
 public function finishRestore($args, $assoc_args)
 {
     define('SHORTINIT', true);
     $wpConfigPath = \WP_CLI\Utils\locate_wp_config();
     require_once $wpConfigPath;
     require ABSPATH . WPINC . '/formatting.php';
     require ABSPATH . WPINC . '/link-template.php';
     require ABSPATH . WPINC . '/shortcodes.php';
     require ABSPATH . WPINC . '/taxonomy.php';
     wp_plugin_directory_constants();
     require_once WP_PLUGIN_DIR . '/versionpress/bootstrap.php';
     $versionPressContainer = DIContainer::getConfiguredInstance();
     /** @var ActionsDefinitionRepository $actionsDefinitionRepository */
     $actionsDefinitionRepository = $versionPressContainer->resolve(VersionPressServices::ACTIONS_DEFINITION_REPOSITORY);
     $actionsDefinitionRepository->restoreAllDefinitionFilesFromHistory();
     // Truncate tables
     /** @var Database $database */
     $database = $versionPressContainer->resolve(VersionPressServices::DATABASE);
     /** @var DbSchemaInfo $dbSchema */
     $dbSchema = $versionPressContainer->resolve(VersionPressServices::DB_SCHEMA);
     $tables = array_map(function ($entityName) use($dbSchema) {
         return $dbSchema->getPrefixedTableName($entityName);
     }, array_merge($dbSchema->getAllEntityNames(), array_map(function ($referenceDetails) {
         return $referenceDetails['junction-table'];
     }, $dbSchema->getAllMnReferences())));
     $tables = array_filter($tables, function ($table) use($database) {
         return $table !== $database->options;
     });
     foreach ($tables as $table) {
         $truncateCmd = "TRUNCATE TABLE `{$table}`";
         @$database->query($truncateCmd);
         // Intentional @ - not existing table is ok for us but TRUNCATE ends with error
     }
     // Create VersionPress tables
     /** @var \VersionPress\Initialization\Initializer $initializer */
     $initializer = $versionPressContainer->resolve(VersionPressServices::INITIALIZER);
     $initializer->createVersionPressTables();
     WP_CLI::success("VersionPress tables created");
     // Install Custom merge driver
     MergeDriverInstaller::installMergeDriver(VP_PROJECT_ROOT, VERSIONPRESS_PLUGIN_DIR, VP_VPDB_DIR);
     WP_CLI::success("Git merge driver added");
     // Run synchronization
     /** @var SynchronizationProcess $syncProcess */
     $syncProcess = $versionPressContainer->resolve(VersionPressServices::SYNCHRONIZATION_PROCESS);
     $syncProcess->synchronizeAll();
     WP_CLI::success("Database synchronized");
     VPCommandUtils::runWpCliCommand('vp-internal', 'flush-regenerable-values', ['require' => __FILE__]);
 }
开发者ID:versionpress,项目名称:versionpress,代码行数:56,代码来源:vp-internal.php

示例2: modify_wp_config

 private static function modify_wp_config($content)
 {
     $wp_config_path = Utils\locate_wp_config();
     $token = "/* That's all, stop editing!";
     list($before, $after) = explode($token, file_get_contents($wp_config_path));
     file_put_contents($wp_config_path, $before . $content . $token . $after);
 }
开发者ID:wturrell,项目名称:wp-cli,代码行数:7,代码来源: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: load_wordpress

 /**
  * Load WordPress, if it hasn't already been loaded
  */
 public function load_wordpress()
 {
     static $wp_cli_is_loaded;
     // Globals not explicitly globalized in WordPress
     global $site_id, $public, $current_site, $current_blog, $path, $shortcode_tags;
     if (!empty($wp_cli_is_loaded)) {
         return;
     }
     $wp_cli_is_loaded = true;
     WP_CLI::debug('Begin WordPress load', 'bootstrap');
     WP_CLI::do_hook('before_wp_load');
     $this->check_wp_version();
     $wp_config_path = Utils\locate_wp_config();
     if (!$wp_config_path) {
         WP_CLI::error("wp-config.php not found.\n" . "Either create one manually or use `wp core config`.");
     }
     WP_CLI::debug('wp-config.php path: ' . $wp_config_path, 'bootstrap');
     WP_CLI::do_hook('before_wp_config_load');
     // Load wp-config.php code, in the global scope
     $wp_cli_original_defined_vars = get_defined_vars();
     eval($this->get_wp_config_code());
     foreach (get_defined_vars() as $key => $var) {
         if (array_key_exists($key, $wp_cli_original_defined_vars) || 'wp_cli_original_defined_vars' === $key) {
             continue;
         }
         $GLOBALS[$key] = $var;
     }
     $this->maybe_update_url_from_domain_constant();
     WP_CLI::do_hook('after_wp_config_load');
     // Load WP-CLI utilities
     require WP_CLI_ROOT . '/php/utils-wp.php';
     // Load Core, mu-plugins, plugins, themes etc.
     require WP_CLI_ROOT . '/php/wp-settings-cli.php';
     // Fix memory limit. See http://core.trac.wordpress.org/ticket/14889
     @ini_set('memory_limit', -1);
     // Load all the admin APIs, for convenience
     require ABSPATH . 'wp-admin/includes/admin.php';
     add_filter('filesystem_method', function () {
         return 'direct';
     }, 99);
     // Handle --user parameter
     if (!defined('WP_INSTALLING')) {
         self::set_user($this->config);
     }
     WP_CLI::debug('Loaded WordPress', 'bootstrap');
     WP_CLI::do_hook('after_wp_load');
 }
开发者ID:wesm87,项目名称:wp-cli,代码行数:50,代码来源:Runner.php

示例5: modify_wp_config

 private static function modify_wp_config($content)
 {
     $wp_config_path = Utils\locate_wp_config();
     $token = "/* That's all, stop editing!";
     $config_contents = file_get_contents($wp_config_path);
     if (false === strpos($config_contents, $token)) {
         return false;
     }
     list($before, $after) = explode($token, $config_contents);
     $content = PHP_EOL . PHP_EOL . trim($content) . PHP_EOL . PHP_EOL;
     file_put_contents($wp_config_path, $before . $content . $token . $after);
     return true;
 }
开发者ID:wp-cli,项目名称:wp-cli,代码行数:13,代码来源:core.php

示例6: setConfigUrl

 private function setConfigUrl($urlConstant, $pathConstant, $defaultPath, $baseUrl)
 {
     if (defined($pathConstant) && constant($pathConstant) !== $defaultPath) {
         $wpConfigDir = dirname(\WP_CLI\Utils\locate_wp_config());
         $relativePathToWpContent = str_replace($wpConfigDir, '', realpath(constant($pathConstant)));
         $url = rtrim(rtrim($baseUrl, '/') . str_replace('//', '/', '/' . $relativePathToWpContent), '/');
         $this->runVPInternalCommand('update-config', [$urlConstant, $url]);
     }
 }
开发者ID:versionpress,项目名称:versionpress,代码行数:9,代码来源:vp.php


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