getWpConfigPath() public static method

public static getWpConfigPath ( )
/**
 * Activates the plugin from a WordPress point of view. Note that for VersionPress
 * to become fully active, the Initializer needs to be run.
 *
 * @see Initializer
 */
function vp_activate()
{
    WpConfigSplitter::split(WordPressMissingFunctions::getWpConfigPath());
    set_transient('vp_just_activated', '1', 10);
}
 private function createCommonConfig()
 {
     $configPath = WordPressMissingFunctions::getWpConfigPath();
     WpConfigSplitter::split($configPath);
 }
Beispiel #3
0
    <div class="welcome-panel-content">

        <h3>VersionPress Activation</h3>


        <p class="about-description">Setting things up for you. It may take a while, please be patient.</p>

        <div class="initialization-progress">
            <?php 
// Set the env name in wp-config.php
if (isset($_GET['envname']) && \VersionPress\Utils\WorkflowUtils::isCloneNameValid($_GET['envname'])) {
    $envName = $_GET['envname'];
} else {
    $envName = 'default';
}
$wpConfigPath = \VersionPress\Utils\WordPressMissingFunctions::getWpConfigPath();
$wpConfigEditor = new \VersionPress\Utils\WpConfigEditor($wpConfigPath, false);
$wpConfigEditor->updateConfigConstant('VP_ENVIRONMENT', $envName);
_vp_show_progress_message("Environment set to '{$envName}'", true);
// Do the initialization
global $versionPressContainer;
/** @var Initializer $initializer */
$initializer = $versionPressContainer->resolve(VersionPressServices::INITIALIZER);
$initializer->onProgressChanged[] = '_vp_show_progress_message';
$initializer->initializeVersionPress();
$successfullyInitialized = VersionPress::isActive();
?>
        </div>

        <?php 
if ($successfullyInitialized) {
 /**
  * Sets or updates constant or variable in wp-config.php
  *
  * ## OPTIONS
  *
  * <constant>
  * : Name of constant or variable that will be changed.
  *
  * <value>
  * : Desired value. Supported types are: string, int, float and bool.
  *
  * [--plain]
  * : The value will be used as is - without type detection, quoting etc.
  *
  * [--variable]
  * : Will set a variable instead of constant. Useful for $table_prefix.
  *
  * [--common]
  * : The constant / variable will be set in wp-config.common.php.
  *
  * @subcommand update-config
  *
  *
  * @when before_wp_load
  */
 public function updateConfig($args = [], $assoc_args = [])
 {
     require_once __DIR__ . '/VPCommandUtils.php';
     require_once __DIR__ . '/../Initialization/WpConfigSplitter.php';
     require_once __DIR__ . '/../Utils/WpConfigEditor.php';
     require_once __DIR__ . '/../Utils/WordPressMissingFunctions.php';
     $wpConfigPath = WordPressMissingFunctions::getWpConfigPath();
     $updateCommonConfig = isset($assoc_args['common']);
     if ($updateCommonConfig) {
         $wpConfigPath = dirname($wpConfigPath) . '/' . WpConfigSplitter::COMMON_CONFIG_NAME;
     }
     if ($wpConfigPath === false) {
         WP_CLI::error('Config file does not exist. Please run `wp core config` first.');
     }
     $constantOrVariableName = $args[0];
     $isVariable = isset($assoc_args['variable']);
     $usePlainValue = isset($assoc_args['plain']);
     $value = $usePlainValue ? $args[1] : VPCommandUtils::fixTypeOfValue($args[1]);
     $wpConfigEditor = new WpConfigEditor($wpConfigPath, $updateCommonConfig);
     try {
         if ($isVariable) {
             $wpConfigEditor->updateConfigVariable($constantOrVariableName, $value, $usePlainValue);
         } else {
             $wpConfigEditor->updateConfigConstant($constantOrVariableName, $value, $usePlainValue);
         }
     } catch (\Exception $e) {
         WP_CLI::error('Cannot find place for defining the ' . ($isVariable ? 'variable' : 'constant') . '. Config was probably edited manually.');
     }
 }