Skip to content

Commit 4d59e47

Browse files
committed
Merge branch 'behat-test-cases' of github.com:abhijitrakas/site-type-wp into behat-test-cases
2 parents cb65409 + d117b9e commit 4d59e47

1 file changed

Lines changed: 59 additions & 0 deletions

File tree

src/WordPress.php

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
use Symfony\Component\Filesystem\Filesystem;
1111
use function EE\Site\Utils\auto_site_name;
1212
use function EE\Site\Utils\get_site_info;
13+
use function EE\Utils\get_flag_value;
1314

1415
/**
1516
* Adds `wp` site type to `ee site` command.
@@ -202,6 +203,9 @@ public function __construct() {
202203
* # Create WordPress site with wildcard ssl
203204
* $ ee site create example.com --type=wp --ssl=le --wildcard
204205
*
206+
* # Create WordPress site with self signed certificate
207+
* $ ee site create example.com --type=wp --ssl=self
208+
*
205209
* # Create WordPress site with remote database
206210
* $ ee site create example.com --type=wp --dbhost=localhost --dbuser=username --dbpass=password
207211
*
@@ -1296,6 +1300,61 @@ public function reload( $args, $assoc_args, $whitelisted_containers = [], $reloa
12961300
}
12971301

12981302

1303+
/**
1304+
* Publishes site online using ngrok.
1305+
*
1306+
* ## OPTIONS
1307+
*
1308+
* <site-name>
1309+
* : Name of website.
1310+
*
1311+
* [--disable]
1312+
* : Take online link down.
1313+
*
1314+
* [--refresh]
1315+
* : Refresh site publish if link has expired.
1316+
*
1317+
* [--token=<token>]
1318+
* : ngrok token.
1319+
*
1320+
* ## EXAMPLES
1321+
*
1322+
* # Publish site online
1323+
* $ ee site publish example.com
1324+
*
1325+
* # Refresh published link if expired
1326+
* $ ee site publish example.com --refresh
1327+
*
1328+
* # Disable online link
1329+
* $ ee site publish example.com --disable
1330+
*
1331+
*/
1332+
public function publish( $args, $assoc_args ) {
1333+
1334+
parent::publish( $args, $assoc_args );
1335+
1336+
$disable = get_flag_value( $assoc_args, 'disable', false );
1337+
$refresh = get_flag_value( $assoc_args, 'refresh', false );
1338+
1339+
if ( $refresh ) {
1340+
return;
1341+
}
1342+
1343+
EE::log( 'Running additional WordPress configurations.' );
1344+
chdir( $this->site_data->site_fs_path );
1345+
if ( $disable ) {
1346+
EE::exec( 'docker-compose exec --user=\'www-data\' php wp plugin delete relative-url' );
1347+
EE::exec( 'docker-compose exec --user=\'www-data\' php wp config delete WP_SITEURL' );
1348+
EE::exec( 'docker-compose exec --user=\'www-data\' php wp config delete WP_HOME' );
1349+
} else {
1350+
EE::exec( 'docker-compose exec --user=\'www-data\' php wp plugin install relative-url --activate' );
1351+
EE::exec( 'docker-compose exec --user=\'www-data\' php wp config set --type=constant WP_SITEURL "\'http://\' . $_SERVER[\'HTTP_HOST\']" --raw' );
1352+
EE::exec( 'docker-compose exec --user=\'www-data\' php wp config set --type=constant WP_HOME "\'http://\' . $_SERVER[\'HTTP_HOST\']" --raw' );
1353+
}
1354+
1355+
EE::success( 'WordPress configurations updated for publish.' );
1356+
}
1357+
12991358
/**
13001359
* Catch and clean exceptions.
13011360
*

0 commit comments

Comments
 (0)