Example #1
0
 public static function getAllInfo()
 {
     $output = [];
     $output['summary'] = [];
     $output['git-info'] = self::getGitInfo();
     $output['wordpress-info'] = self::getWordPressInfo();
     $output['php-info'] = self::getPhpInfo();
     $output['permission-info'] = self::getPermissionInfo();
     $output['summary']['wordpress-version'] = $output['wordpress-info']['wp-version'];
     $output['summary']['versionpress-version'] = VersionPress::getVersion();
     $output['summary']['operating-system'] = php_uname();
     $output['summary']['php-version'] = phpversion();
     $output['summary']['php-sapi'] = php_sapi_name();
     $output['summary']['git-version'] = isset($output['git-info']['git-version']) ? $output['git-info']['git-version'] : '';
     $output['summary']['git-full-path'] = isset($output['git-info']['git-full-path']) ? $output['git-info']['git-full-path'] : '';
     return $output;
 }
 /**
  * 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);
 }
Example #3
0
 public static function getAllInfo()
 {
     global $versionPressContainer;
     /** @var VersionPressConfig $vpConfig */
     $vpConfig = $versionPressContainer->resolve(VersionPressServices::VP_CONFIGURATION);
     $output = array();
     $output['summary'] = array();
     $output['git-info'] = self::getGitInfo();
     $output['wordpress-info'] = self::getWordPressInfo();
     $output['php-info'] = self::getPhpInfo();
     $output['permission-info'] = self::getPermissionInfo();
     $output['summary']['wordpress-version'] = $output['wordpress-info']['wp-version'];
     $output['summary']['versionpress-version'] = VersionPress::getVersion();
     $output['summary']['operating-system'] = php_uname();
     $output['summary']['php-version'] = phpversion();
     $output['summary']['php-sapi'] = php_sapi_name();
     $output['summary']['custom-vp-config'] = $vpConfig->customConfig;
     $output['summary']['git-version'] = isset($output['git-info']['git-version']) ? $output['git-info']['git-version'] : '';
     $output['summary']['git-full-path'] = isset($output['git-info']['git-full-path']) ? $output['git-info']['git-full-path'] : '';
     return $output;
 }
function vp_enqueue_admin_styles_and_scripts()
{
    $vpVersion = VersionPress::getVersion();
    wp_enqueue_style('versionpress_admin_style', plugins_url('admin/public/css/style.css', VERSIONPRESS_PLUGIN_FILE), [], $vpVersion);
    wp_enqueue_style('versionpress_admin_icons', plugins_url('admin/public/icons/style.css', VERSIONPRESS_PLUGIN_FILE), [], $vpVersion);
    wp_enqueue_script('versionpress_admin_script', plugins_url('admin/public/js/vp-admin.js', VERSIONPRESS_PLUGIN_FILE), [], $vpVersion);
}
Example #5
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>
Example #6
0
function vp_admin_bar_warning(WP_Admin_Bar $adminBar)
{
    if (!current_user_can('activate_plugins')) {
        return;
    }
    $adminBarText = "<span style=\"color:#FF8800;font-weight:bold\">VersionPress EAP running</span>";
    $popoverTitle = "Note";
    $popoverText = "<p style='margin-top: 5px;'>You are running <strong>VersionPress " . VersionPress::getVersion() . "</strong> which is an <strong style='font-size: 1.15em;'>EAP release</strong>. Please understand that EAP releases are early versions of the software and as such might not fully support certain workflows, 3<sup>rd</sup> party plugins, hosts etc.<br /><br /><strong>We recommend that you keep a safe backup of the site at all times</strong></p>";
    $popoverText .= "<p><a href='http://docs.versionpress.net/en/release-notes' target='_blank'>Learn more about VersionPress releases</a></p>";
    $adminBar->add_node(array('id' => 'vp-running', 'title' => "<a href='#' class='ab-item' id='vp-warning'>{$adminBarText}</a>\n            <script>\n            var warning = jQuery('#vp-warning');\n            var customPopoverClass = \"versionpress-alpha\"; // used to identify the popover later\n\n            warning.webuiPopover({title:\"{$popoverTitle}\", content: \"{$popoverText}\", closeable: true, style: customPopoverClass, width:450});\n            </script>", 'parent' => 'top-secondary'));
}
Example #7
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 {
<?php

use VersionPress\VersionPress;
$apiConfig = ['root' => get_home_url(), 'adminUrl' => get_admin_url(), 'urlPrefix' => rest_get_url_prefix(), 'queryParam' => 'rest_route', 'permalinkStructure' => get_option('permalink_structure'), 'nonce' => wp_create_nonce('wp_rest')];
?>
<script>
    var VP_API_Config = <?php 
echo json_encode($apiConfig);
?>
</script>

<?php 
$vpVersion = VersionPress::getVersion();
wp_enqueue_style('versionpress_gui_style', plugins_url('../public/gui/app.css', __FILE__), [], $vpVersion);
wp_enqueue_script('versionpress_gui_script', plugins_url('../public/gui/app.js', __FILE__), [], $vpVersion);
Example #9
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();
 }
 /**
  * @param TrackedChangeInfo[] $changeInfoList
  * @param string|null $version
  * @param SortingStrategy $sortingStrategy
  */
 public function __construct($changeInfoList, $version = null, $sortingStrategy = null)
 {
     $this->changeInfoList = $changeInfoList;
     $this->version = $version === null ? VersionPress::getVersion() : $version;
     $this->sortingStrategy = $sortingStrategy === null ? new SortingStrategy() : $sortingStrategy;
 }
 /**
  * @param TrackedChangeInfo[] $changeInfoList
  * @param string|null $version
  * @param string|null $environment
  */
 public function __construct($changeInfoList, $version = null, $environment = null)
 {
     $this->changeInfoList = $changeInfoList;
     $this->version = $version === null ? VersionPress::getVersion() : $version;
     $this->environment = $environment ?: VersionPress::getEnvironment();
 }
Example #12
-1
 private function abortInitialization()
 {
     touch(VERSIONPRESS_PLUGIN_DIR . '/.abort-initialization');
     if (VersionPress::isActive()) {
         @unlink(VERSIONPRESS_ACTIVATION_FILE);
     }
     vp_disable_maintenance();
     throw new InitializationAbortedException();
 }