-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* [N/A] Fix a small bug in Gravatar fix * [N/A] Fix issue where WordPress isn't installed on repo clone. * [#111] Pre-populate Site info for fresh install * [#111] Include ENV reading step * [#111] Move VigetWP Composer Install to ddev post-start hook * [#111] Added Composer version to VigetWP MU Plugin Composer File
- Loading branch information
Showing
5 changed files
with
70 additions
and
36 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
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
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 |
---|---|---|
|
@@ -67,44 +67,76 @@ class PostInstallScript extends ComposerScript { | |
]; | ||
|
||
/** | ||
* Perform the actions within this file. | ||
* Initialize the script. | ||
* | ||
* @param Event $event | ||
* @param bool $fromExecute | ||
* | ||
* @return void | ||
*/ | ||
public static function execute( Event $event ): void { | ||
public static function init( Event $event, bool $fromExecute = false ): void { | ||
self::setEvent( $event ); | ||
|
||
// Only run the rest of the script if we are in development mode. | ||
if ( !$event->isDevMode() ) { | ||
return; | ||
} | ||
|
||
// Load DDEV Environment variables. | ||
self::loadDDEVEnvironmentVars(); | ||
|
||
self::wait(); | ||
|
||
if ( self::needsSetup() ) { | ||
|
||
// Download WordPress | ||
self::downloadWordPress(); | ||
|
||
self::wait( 2 ); | ||
|
||
// Populate the database. | ||
self::populateDatabase(); | ||
if ( $fromExecute ) { | ||
// Give database population options | ||
self::populateDatabase(); | ||
} else { | ||
// Pre-configure the Setup | ||
self::$info = [ | ||
'title' => 'WordPress Site Starter', | ||
'description' => 'A project developed by Viget.', | ||
'url' => 'https://wpstarter.ddev.site', | ||
'username' => 'viget', | ||
'email' => '[email protected]', | ||
]; | ||
|
||
// Do not activate Project Plugins | ||
unset( self::$activatePlugins['seo-by-rank-math'] ); | ||
unset( self::$activatePlugins['wordfence'] ); | ||
|
||
// Automatically install WordPress | ||
self::doFreshInstall(); | ||
} | ||
|
||
// Remove the core Twenty-X themes. | ||
self::deleteCoreThemes(); | ||
|
||
// Remove Hello Dolly. | ||
self::deleteCorePlugins(); | ||
|
||
// Show the success message. | ||
self::renderSuccessMessage(); | ||
} | ||
} | ||
|
||
/** | ||
* Perform the actions within this file. | ||
* | ||
* @param Event $event | ||
* | ||
* @return void | ||
*/ | ||
public static function execute( Event $event ): void { | ||
self::setEvent( $event ); | ||
|
||
// Only run the rest of the script if we are in development mode. | ||
if ( !$event->isDevMode() ) { | ||
return; | ||
} | ||
|
||
// Run the Viget WP Composer Install | ||
self::vigetWPComposerInstall(); | ||
// Initialize the script. | ||
self::init( $event, true ); | ||
} | ||
|
||
/** | ||
|
@@ -263,6 +295,16 @@ private static function populateDatabase(): void { | |
return; | ||
} | ||
|
||
// Run a fresh WP Install | ||
self::doFreshInstall(); | ||
} | ||
|
||
/** | ||
* Perform a fresh WordPress install. | ||
* | ||
* @return void | ||
*/ | ||
private static function doFreshInstall(): void { | ||
// Run the WordPress Installation | ||
self::installWordPress(); | ||
|
||
|
@@ -289,9 +331,6 @@ private static function populateDatabase(): void { | |
|
||
// Configure plugins. | ||
self::configurePlugins(); | ||
|
||
// Show the success message. | ||
self::renderSuccessMessage(); | ||
} | ||
|
||
/** | ||
|
@@ -536,8 +575,13 @@ private static function activatePlugins(): void { | |
private static function configurePlugins(): void { | ||
self::writeComment( 'Configuring plugins...' ); | ||
|
||
self::configureRankMath(); | ||
self::configureWordfence(); | ||
if( ! empty( self::$activatePlugins['seo-by-rank-math'] ) ) { | ||
self::configureRankMath(); | ||
} | ||
|
||
if( ! empty( self::$activatePlugins['wordfence'] ) ) { | ||
self::configureWordfence(); | ||
} | ||
|
||
self::writeInfo( 'Plugins configured.' ); | ||
} | ||
|
@@ -662,21 +706,4 @@ public static function renderSuccessMessage(): void { | |
|
||
self::writeLine( $success ); | ||
} | ||
|
||
/** | ||
* Run the Viget WP Composer Installer. | ||
* | ||
* @return void | ||
*/ | ||
private static function vigetWPComposerInstall(): void { | ||
self::writeInfo( 'Running Viget WP Composer Install...' ); | ||
|
||
// Run composer install from the viget-wp directory | ||
$directory = self::translatePath( './wp-content/mu-plugins/viget-wp' ); | ||
$cmd = 'composer install -d ' . escapeshellarg( $directory ); | ||
|
||
self::runCommand( $cmd ); | ||
|
||
self::writeInfo( 'VigetWP Composer Install complete.' ); | ||
} | ||
} |
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
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