isActive() public static method

Returns true if VersionPress is active. Note that active != activated and being active means that VersionPress is tracking changes.
public static isActive ( ) : boolean
return boolean
示例#1
0
 /**
  * Commits all changes made by Composer.
  *
  * @subcommand commit-composer-changes
  */
 public function commitComposerChanges($args, $assoc_args)
 {
     if (!VersionPress::isActive()) {
         WP_CLI::error('VersionPress is not active. Changes will be not committed.');
     }
     $pluginsAndThemesBeforeUpdate = get_transient($this->pluginsThemesTransient);
     delete_transient($this->pluginsThemesTransient);
     $currentPluginsAndThemes = $this->getPackages();
     $plugins = array_merge($pluginsAndThemesBeforeUpdate['plugins'], $currentPluginsAndThemes['plugins']);
     $themes = array_merge($pluginsAndThemesBeforeUpdate['themes'], $currentPluginsAndThemes['themes']);
     $changes = $this->detectChanges();
     $installedPackages = $changes['installed'];
     $removedPackages = $changes['removed'];
     $updatedPackages = $changes['updated'];
     $this->forceRelatedActions('install', $installedPackages, $plugins, $themes);
     $this->forceRelatedActions('delete', $removedPackages, $plugins, $themes);
     $this->forceRelatedActions('update', $updatedPackages, $plugins, $themes);
 }
示例#2
0
/**
 * Creates random GUID that is not based on URL
 *
 * @param array $data Sanitized post data
 * @param array $postarr Raw post data
 * @return array
 */
function vp_generate_post_guid($data, $postarr)
{
    if (!VersionPress::isActive()) {
        return $data;
    }
    if (empty($postarr['ID'])) {
        // it's insert not update
        $protocol = is_ssl() ? 'https://' : 'http://';
        $data['guid'] = $protocol . IdUtil::newUuid();
    }
    return $data;
}
示例#3
0
<?php

use VersionPress\Configuration\VersionPressConfig;
use VersionPress\DI\VersionPressServices;
use VersionPress\VersionPress;
defined('ABSPATH') or die("Direct access not allowed");
global $versionPressContainer;
/** @var VersionPressConfig $vpConfig */
$vpConfig = $versionPressContainer->resolve(VersionPressServices::VP_CONFIGURATION);
?>

<div id="vp" class="wrap vp-index">
<?php 
if (isset($_GET['init_versionpress']) && !VersionPress::isActive()) {
    require_once "inc/activate.php";
} elseif (!VersionPress::isActive()) {
    require_once "inc/activationPanel.php";
} elseif ($vpConfig->mergedConfig['gui'] === 'html') {
    require_once "inc/admin.php";
} else {
    require_once "inc/javascriptGui.php";
}
?>
</div>
示例#4
0
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) {
    ?>
            <p class="initialization-done">All done, we're now redirecting you (or <a
                    href="<?php 
    menu_page_url('versionpress', false);
    ?>
">click here</a>).
            </p>
            <?php 
    JsRedirect::redirect(menu_page_url('versionpress', false), InitializationConfig::REDIRECT_AFTER_MS);
} else {
示例#5
0
 /**
  * Rollbacks site to the same state as it was in the specified commit.
  *
  * ## OPTIONS
  *
  * <commit>
  * : Hash of commit.
  *
  * ## EXAMPLES
  *
  *     wp vp rollback a34bc28
  *
  *
  * @when before_wp_load
  *
  */
 public function rollback($args = [], $assoc_args = [])
 {
     global $versionPressContainer;
     if (!VersionPress::isActive()) {
         WP_CLI::error('This site is not tracked by VersionPress. Please run "wp vp activate" first.');
     }
     /** @var Reverter $reverter */
     $reverter = $versionPressContainer->resolve(VersionPressServices::REVERTER);
     /** @var GitRepository $repository */
     $repository = $versionPressContainer->resolve(VersionPressServices::GIT_REPOSITORY);
     $initialCommitHash = $this->getInitialCommitHash($repository);
     $hash = $args[0];
     $log = $repository->log($hash);
     if (!preg_match('/^[0-9a-f]+$/', $hash) || count($log) === 0) {
         WP_CLI::error("Commit '{$hash}' does not exist.");
     }
     if (!$repository->wasCreatedAfter($hash, $initialCommitHash) && $log[0]->getHash() !== $initialCommitHash) {
         WP_CLI::error('Cannot roll back before initial commit');
     }
     if ($log[0]->getHash() === $repository->getLastCommitHash()) {
         WP_CLI::error('Nothing to commit. Current state is the same as the one you want rollback to.');
     }
     $this->switchMaintenance('on');
     $status = $reverter->rollback([$hash]);
     if ($status === RevertStatus::NOTHING_TO_COMMIT) {
         WP_CLI::error("Nothing to commit. Current state is the same as the one you want rollback to.", false);
     }
     if ($status === RevertStatus::NOT_CLEAN_WORKING_DIRECTORY) {
         WP_CLI::error("The working directory is not clean. Please commit your changes.", false);
     }
     if ($status === RevertStatus::OK) {
         WP_CLI::success("Rollback was successful.");
     }
     $this->switchMaintenance('off');
     $this->flushRewriteRules();
 }
示例#6
-1
 private function abortInitialization()
 {
     touch(VERSIONPRESS_PLUGIN_DIR . '/.abort-initialization');
     if (VersionPress::isActive()) {
         @unlink(VERSIONPRESS_ACTIVATION_FILE);
     }
     vp_disable_maintenance();
     throw new InitializationAbortedException();
 }