-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from humanmade/initial-version
Initial CMS installer
- Loading branch information
Showing
5 changed files
with
171 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
# platform-cms-installer | ||
Composer plugin for installing the platform CMS | ||
# Platform CMS Installer | ||
|
||
Composer plugin for installing the platform CMS. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
{ | ||
"name": "humanmade/cms-installer", | ||
"description": "CMS Installer plugin for Platform", | ||
"type": "composer-plugin", | ||
"license": "GPL-2.0", | ||
"authors": [ | ||
{ | ||
"name": "Human Made", | ||
"email": "[email protected]" | ||
} | ||
], | ||
"require": { | ||
"php": ">=7.1", | ||
"johnpbloch/wordpress": "5.1.1", | ||
"composer-plugin-api": "^1.1" | ||
}, | ||
"extra": { | ||
"class": "HM\\Platform\\CMS\\Composer\\Plugin" | ||
}, | ||
"autoload": { | ||
"classmap": [ | ||
"inc/" | ||
] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
<?php | ||
|
||
namespace HM\Platform\CMS\Composer; | ||
|
||
use Composer\Composer; | ||
use Composer\EventDispatcher\EventSubscriberInterface; | ||
use Composer\IO\IOInterface; | ||
use Composer\Plugin\PluginInterface; | ||
|
||
class Plugin implements PluginInterface, EventSubscriberInterface { | ||
|
||
/** | ||
* Activate is not used, but is part of the abstract class. | ||
* | ||
* @param Composer $composer | ||
* @param IOInterface $io | ||
*/ | ||
public function activate( Composer $composer, IOInterface $io ) { | ||
} | ||
|
||
/** | ||
* Register the composer events we want to run on. | ||
* | ||
* @return array | ||
*/ | ||
public static function getSubscribedEvents() : array { | ||
return [ | ||
'post-update-cmd' => [ 'install_files' ], | ||
'pre-install-cmd' => [ 'install_files' ], | ||
]; | ||
} | ||
|
||
/** | ||
* Install additional files to the project on update / install | ||
*/ | ||
public function install_files() { | ||
$source = dirname( __DIR__, 2 ); | ||
$dest = dirname( $source, 3 ); | ||
|
||
copy( $source . '/index.php', $dest . '/index.php' ); | ||
copy( $source . '/wp-config.php', $dest . '/wp-config.php' ); | ||
|
||
// Update the .gitignore to include the wp-config.php, WordPress, the index.php | ||
// as these files should not be included in VCS. | ||
if ( ! file_exists( $dest . '/.gitignore' ) ) { | ||
file_put_contents( $dest . '/.gitignore', "wordpress/\nindex.php\nwp-config.php" ); | ||
} | ||
|
||
if ( ! is_dir( $dest . '/content' ) ) { | ||
mkdir( $dest . '/content' ); | ||
} | ||
if ( ! is_dir( $dest . '/content/plugins' ) ) { | ||
mkdir( $dest . '/content/plugins' ); | ||
} | ||
if ( ! is_dir( $dest . '/content/themes' ) ) { | ||
mkdir( $dest . '/content/themes' ); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?php | ||
/** | ||
* Front to the WordPress application. This file doesn't do anything, but loads | ||
* wp-blog-header.php which does and tells WordPress to load the theme. | ||
* | ||
* @package WordPress | ||
* | ||
* DO NOT EDIT THIS FILE. | ||
*/ | ||
|
||
/** | ||
* Tells WordPress to load the WordPress theme and output it. | ||
* | ||
* @var bool | ||
*/ | ||
define( 'WP_USE_THEMES', true ); | ||
|
||
/** Loads the WordPress Environment and Template */ | ||
require( dirname( __FILE__ ) . '/wordpress/wp-blog-header.php' ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
<?php | ||
|
||
/* | ||
* Main config file for loading Platform. | ||
* | ||
* DO NOT EDIT THIS FILE. | ||
* | ||
* All configuration should be done either in your project's composer.json or `config/` | ||
* directory. | ||
*/ | ||
|
||
// Provide a reference to the app root directory early. | ||
define( 'HM\\Platform\\ROOT_DIR', __DIR__ ); | ||
|
||
// Load the plugin API (like add_action etc) early, so everything loaded | ||
// via the Composer autoloaders can using actions. | ||
require_once __DIR__ . '/wordpress/wp-includes/plugin.php'; | ||
|
||
// Load the whole autoloader very early, this will also include | ||
// all `autoload.files` from all modules. | ||
require_once __DIR__ . '/vendor/autoload.php'; | ||
|
||
do_action( 'hm-platform.loaded_autoloader' ); | ||
|
||
if ( ! defined( 'ABSPATH' ) ) { | ||
define( 'ABSPATH', __DIR__ . '/wordpress/' ); | ||
} | ||
|
||
if ( ! defined( 'WP_CONTENT_DIR' ) ) { | ||
define( 'WP_CONTENT_DIR', __DIR__ . '/content' ); | ||
} | ||
|
||
if ( ! defined( 'WP_CONTENT_URL' ) ) { | ||
$protocol = ! empty( $_SERVER['HTTPS'] ) ? 'https' : 'http'; | ||
define( 'WP_CONTENT_URL', $protocol . '://' . $_SERVER['HTTP_HOST'] . '/content' ); | ||
} | ||
|
||
if ( ! defined( 'WP_INSTALLING' ) || ! WP_INSTALLING ) { | ||
// Multisite is always enabled, unless some spooky | ||
// early loading code tried to change that of course. | ||
if ( ! defined( 'MULTISITE' ) ) { | ||
define( 'MULTISITE', true ); | ||
} | ||
} | ||
|
||
$table_prefix = getenv( 'TABLE_PREFIX' ) ?: 'wp_'; | ||
|
||
/* | ||
* DB constants are expected to be provided by other modules, as they are | ||
* environment specific. | ||
*/ | ||
$required_constants = [ | ||
'DB_HOST', | ||
'DB_NAME', | ||
'DB_USER', | ||
'DB_PASSWORD', | ||
]; | ||
|
||
foreach ( $required_constants as $constant ) { | ||
if ( ! defined( $constant ) ) { | ||
die( "$constant constant is not defined." ); | ||
} | ||
} | ||
|
||
require_once ABSPATH . 'wp-settings.php'; |