versionpress / support

Unofficial support for VersionPress. Note that VersionPress is currently not being developed: https://github.com/versionpress/versionpress/issues/1481.
19 stars 7 forks source link

Creating a Plugin for VersionPress settings #171

Open emaildano opened 4 years ago

emaildano commented 4 years ago

Hey!

I'm working on adding support for VersionPress to Shifter (https://www.getshifter.io). To do that I need to modify where the .git file is stored.

For example, I would like for it to be stored in wp-content/uploads/.

The cache with supporting this on Shifter is that the wp-config.php file is managed. If I make any edits the wp-config file will be overwritten. So, I'm thinking this should be added as a plugin.

Here is the plugin I'm working on but I can't get it to move the .git folder. Can you take a look? The gist if that anything related to VersionPress cannot be stored in the root directory.

I'd be happy to post this up on on the Shifter blog once we can offer support for VersionPress as a customers have asked for it.

Thanks!

<?php

/**
 *
 * @link    https://www.getshifter.io
 * @since   0.1.0
 * @package Shifter VersionPress Helper
 *
 * @wordpress-plugin
 * Plugin Name:       Shifter VersionPress Helper
 * Plugin URI:        https://github.com/getshifter/shifter-versionpress-helper
 * Description:       Helper tool for using VersionPress on Shifter.
 * Version:           0.1.0
 * Author:            DigitalCube
 * Author URI:        https://www.getshifter.io
 * License:           GPL-2.0+
 * License URI:       http://www.gnu.org/licenses/gpl-2.0.txt
 * Text Domain:       shifter-versionpress-helper
 * Domain Path:       /languages
 */

/**
 * Shifter VersionPress Settings
 */
function shifter_versionpress_helper() {

  /**
   * VersionPress Project Root
   * @link  https://docs.versionpress.net/en/getting-started/configuration/#vp_project_root
   * @since 4.0-beta2
   */
  if (class_exists('\VersionPress')) {
    $upload_dir = wp_get_upload_dir();
    $save_path = $upload_dir['basedir'] . '/versionpress';
    define('VP_PROJECT_ROOT', $save_path);
  }

}

add_action('init', 'shifter_versionpress_helper');
borekb commented 4 years ago

Hi @emaildano, VersionPress controls the whole WordPress installation, I'm not sure if what you're trying to achieve is possible. Can you describe in more detail how you think it would work?

emaildano commented 4 years ago

@borekb

I want to modify some of the VersionPress settings. Really just where the .git file is stored.

In your docs you can do that 2 ways. 1. By using the WP-CLi or 2. Adding those constants to wp-config.php. In my case, I can't do either.

So, what I'm thinking is: define those constants in a mu-plugin. Will that work?

borekb commented 4 years ago

The .git directory needs to be in the site root so that commands like git status work. Also note that VersionPress needs to have write access to all the files of the site – that's how it works. I'm not that familiar with Shifter but a bit it sounds that you try to bend VersionPress in ways that it cannot be bent 😄.