Skip to content

Commit

Permalink
Fixes to PostInstall Script
Browse files Browse the repository at this point in the history
  • Loading branch information
bd-viget committed Nov 13, 2024
1 parent 8bd1f24 commit 516e42c
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions bin/composer-scripts/ProjectEvents/PostInstallScript.php
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,11 @@ public static function downloadWordPress(): void {
* @return void
*/
private static function deleteCoreThemes(): void {
if ( ! self::isWordPressInstalled() ) {
self::writeWarning( 'Could not delete stock WordPress themes.' );
return;
}

self::writeInfo( 'Deleting stock WordPress themes...' );

$themes = [
Expand Down Expand Up @@ -238,6 +243,11 @@ private static function deleteCoreThemes(): void {
* @return void
*/
private static function deleteCorePlugins(): void {
if ( ! self::isWordPressInstalled() ) {
self::writeWarning( 'Could not delete stock WordPress plugins.' );
return;
}

self::writeInfo( 'Deleting stock WordPress plugins...' );

foreach ( self::$deletePlugins as $plugin ) {
Expand Down Expand Up @@ -275,7 +285,7 @@ private static function deletePlugin( string $plugin ): void {
* @return void
*/
private static function populateDatabase(): void {
if ( self::isWordPressInstalled() ) {
if ( self::isWordPressDbInstalled() ) {
self::writeInfo( 'WordPress is already installed.' );
return;
}
Expand Down Expand Up @@ -315,7 +325,7 @@ private static function doFreshInstall(): void {
self::wait( 2 );

// Make sure WordPress was installed successfully.
if ( ! self::isWordPressInstalled() ) {
if ( ! self::isWordPressInstalled() || ! self::isWordPressDbInstalled() ) {
self::writeError( 'WordPress installation failed.' );
return;
}
Expand Down Expand Up @@ -419,6 +429,15 @@ private static function isWordPressInstalled(): bool {
return false !== shell_exec( 'wp core is-installed' );
}

/**
* Check if WordPress Database is installed.
*
* @return bool
*/
private static function isWordPressDbInstalled(): bool {
return boolval( shell_exec( 'wp option get siteurl --quiet' ) );
}

/**
* Import database file
*
Expand Down

0 comments on commit 516e42c

Please sign in to comment.