@@ -112,13 +112,14 @@ public function __construct() {
112
112
* [--wp]
113
113
* : WordPress website.
114
114
*
115
- * [--wpredis ]
116
- * : Use redis for WordPress.
115
+ * [--cache ]
116
+ * : Use redis cache for WordPress.
117
117
*
118
- * [--wpsubdir]
118
+ *
119
+ * [--mu=<subdir>]
119
120
* : WordPress sub-dir Multi-site.
120
121
*
121
- * [--wpsubdom ]
122
+ * [--mu=<subdom> ]
122
123
* : WordPress sub-domain Multi-site.
123
124
*
124
125
* [--title=<title>]
@@ -191,17 +192,20 @@ public function create( $args, $assoc_args ) {
191
192
$ this ->logger ->debug ( 'args: ' , $ args );
192
193
$ this ->logger ->debug ( 'assoc_args: ' , empty ( $ assoc_args ) ? array ( 'NULL ' ) : $ assoc_args );
193
194
$ this ->site ['name ' ] = strtolower ( EE \Utils \remove_trailing_slash ( $ args [0 ] ) );
194
- $ this ->site ['type ' ] = EE \Utils \get_type ( $ assoc_args , [ 'wp ' , 'wpsubdom ' , 'wpsubdir ' ], 'wp ' );
195
- if ( false === $ this ->site ['type ' ] ) {
196
- EE ::error ( 'Invalid arguments ' );
195
+
196
+ $ mu = EE \Utils \get_flag_value ( $ assoc_args , 'mu ' );
197
+
198
+ if ( isset ( $ assoc_args ['mu ' ] ) && ! in_array ( $ mu , [ 'subdom ' , 'subdir ' ], true ) ) {
199
+ EE ::error ( "Unrecognized multi-site parameter: $ mu. Only `--mu=subdom` and `--mu=subdir` are supported. " );
197
200
}
201
+ $ this ->site ['type ' ] = $ mu ?? 'wp ' ;
198
202
199
203
if ( EE ::db ()::site_in_db ( $ this ->site ['name ' ] ) ) {
200
204
EE ::error ( sprintf ( "Site %1 \$s already exists. If you want to re-create it please delete the older one using: \n`ee site delete %1 \$s` " , $ this ->site ['name ' ] ) );
201
205
}
202
206
203
207
$ this ->proxy_type = EE_PROXY_TYPE ;
204
- $ this ->cache_type = empty ( $ assoc_args[ ' wpredis ' ] ) ? ' none ' : ' wpredis ' ;
208
+ $ this ->cache_type = EE \ Utils \get_flag_value ( $ assoc_args, ' cache ' ) ;
205
209
$ this ->le = EE \Utils \get_flag_value ( $ assoc_args , 'letsencrypt ' );
206
210
$ this ->site ['title ' ] = EE \Utils \get_flag_value ( $ assoc_args , 'title ' , $ this ->site ['name ' ] );
207
211
$ this ->site ['user ' ] = EE \Utils \get_flag_value ( $ assoc_args , 'admin_user ' , 'admin ' );
@@ -260,7 +264,7 @@ public function info( $args ) {
260
264
[ 'DB User ' , $ this ->db ['user ' ] ],
261
265
[ 'DB Password ' , $ this ->db ['pass ' ] ],
262
266
[ 'E-Mail ' , $ this ->site ['email ' ] ],
263
- [ 'Cache Type ' , $ this ->cache_type ],
267
+ [ 'Cache ' , $ this ->cache_type ? ' Enabled ' : ' none ' ],
264
268
[ 'SSL ' , $ ssl ],
265
269
];
266
270
@@ -284,15 +288,15 @@ private function configure_site_files() {
284
288
$ site_conf_env = $ this ->site ['root ' ] . '/.env ' ;
285
289
$ site_nginx_default_conf = $ site_conf_dir . '/nginx/default.conf ' ;
286
290
$ site_php_ini = $ site_conf_dir . '/php-fpm/php.ini ' ;
287
- $ server_name = ( 'wpsubdom ' === $ this ->site ['type ' ] ) ? $ this ->site ['name ' ] . ' *. ' . $ this ->site ['name ' ] : $ this ->site ['name ' ];
291
+ $ server_name = ( 'subdom ' === $ this ->site ['type ' ] ) ? $ this ->site ['name ' ] . ' *. ' . $ this ->site ['name ' ] : $ this ->site ['name ' ];
288
292
$ process_user = posix_getpwuid ( posix_geteuid () );
289
293
290
294
EE ::log ( 'Creating WordPress site ' . $ this ->site ['name ' ] );
291
295
EE ::log ( 'Copying configuration files. ' );
292
296
293
297
$ filter = [];
294
298
$ filter [] = $ this ->site ['type ' ];
295
- $ filter [] = $ this ->cache_type ;
299
+ $ filter [] = $ this ->cache_type ? ' redis ' : ' none ' ;
296
300
$ filter [] = $ this ->le ;
297
301
$ filter [] = $ this ->db ['host ' ];
298
302
$ site_docker = new Site_WP_Docker ();
@@ -339,19 +343,19 @@ private function configure_site_files() {
339
343
/**
340
344
* Function to generate default.conf from mustache templates.
341
345
*
342
- * @param string $site_type Type of site (wpsubdom, wpredis etc..).
343
- * @param string $cache_type Type of cache(wpredis or none) .
344
- * @param string $server_name Name of server to use in virtual_host.
346
+ * @param string $site_type Type of site (subdom, subdir etc..).
347
+ * @param boolean $cache_type Cache enabled or not .
348
+ * @param string $server_name Name of server to use in virtual_host.
345
349
*
346
350
* @return string Parsed mustache template string output.
347
351
*/
348
352
private function generate_default_conf ( $ site_type , $ cache_type , $ server_name ) {
349
353
350
354
$ default_conf_data ['site_type ' ] = $ site_type ;
351
355
$ default_conf_data ['server_name ' ] = $ server_name ;
352
- $ default_conf_data ['include_php_conf ' ] = $ cache_type !== ' wpredis ' ;
353
- $ default_conf_data ['include_wpsubdir_conf ' ] = $ site_type === 'wpsubdir ' ;
354
- $ default_conf_data ['include_redis_conf ' ] = $ cache_type === ' wpredis ' ;
356
+ $ default_conf_data ['include_php_conf ' ] = ! $ cache_type ;
357
+ $ default_conf_data ['include_wpsubdir_conf ' ] = $ site_type === 'subdir ' ;
358
+ $ default_conf_data ['include_redis_conf ' ] = $ cache_type ;
355
359
356
360
return EE \Utils \mustache_render ( SITE_WP_TEMPLATE_ROOT . '/config/nginx/default.conf.mustache ' , $ default_conf_data );
357
361
}
@@ -415,7 +419,8 @@ private function create_site( $assoc_args ) {
415
419
}
416
420
417
421
if ( $ this ->le ) {
418
- $ this ->init_le ();
422
+ $ wildcard = 'subdom ' === $ this ->site ['type ' ] ? true : false ;
423
+ $ this ->init_le ( $ this ->site ['name ' ], $ this ->site ['root ' ], $ wildcard );
419
424
}
420
425
$ this ->info ( [ $ this ->site ['name ' ] ], [] );
421
426
$ this ->create_site_db_entry ();
@@ -520,9 +525,9 @@ private function install_wp() {
520
525
$ wp_install_command = 'install ' ;
521
526
$ maybe_multisite_type = '' ;
522
527
523
- if ( 'wpsubdom ' === $ this ->site ['type ' ] || 'wpsubdir ' === $ this ->site ['type ' ] ) {
528
+ if ( 'subdom ' === $ this ->site ['type ' ] || 'subdir ' === $ this ->site ['type ' ] ) {
524
529
$ wp_install_command = 'multisite-install ' ;
525
- $ maybe_multisite_type = $ this ->site ['type ' ] === 'wpsubdom ' ? '--subdomains ' : '' ;
530
+ $ maybe_multisite_type = $ this ->site ['type ' ] === 'subdom ' ? '--subdomains ' : '' ;
526
531
}
527
532
528
533
$ install_command = sprintf ( 'docker-compose exec --user= \'www-data \' php wp core %s --url= \'%s \' --title= \'%s \' --admin_user= \'%s \'' , $ wp_install_command , $ this ->site ['name ' ], $ this ->site ['title ' ], $ this ->site ['user ' ] );
@@ -550,7 +555,7 @@ private function create_site_db_entry() {
550
555
'site_title ' => $ this ->site ['title ' ],
551
556
'site_command ' => $ this ->command ,
552
557
'proxy_type ' => $ this ->proxy_type ,
553
- 'cache_type ' => $ this ->cache_type ,
558
+ 'cache_type ' => ( int ) $ this ->cache_type ,
554
559
'site_path ' => $ this ->site ['root ' ],
555
560
'db_name ' => $ this ->db ['name ' ],
556
561
'db_user ' => $ this ->db ['user ' ],
0 commit comments