Skip to content

Commit 6d5cf8a

Browse files
committed
v 0.141.4
wpconfig : - clean some vars. - check https. - force add env.
1 parent 5c5e73e commit 6d5cf8a

File tree

3 files changed

+33
-21
lines changed

3 files changed

+33
-21
lines changed

bin/wpconfig.sh

Lines changed: 25 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ function wputools__wpconfig_set_values(){
1515
_WPCLICOMMAND config set WP_MAX_MEMORY_LIMIT 256M;
1616
_WPCLICOMMAND config set AUTOMATIC_UPDATER_DISABLED true;
1717
_WPCLICOMMAND config set WP_AUTO_UPDATE_CORE false;
18+
_WPCLICOMMAND config set WP_ENVIRONMENT_TYPE 'local';
1819
}
1920

2021
###################################
@@ -38,19 +39,26 @@ wpconfig_site_id=$(bashutilities_get_user_var "- What is your project ID?" "proj
3839
wpconfig_site_prefix=$(bashutilities_get_user_var "- What is your site prefix?" "wp_");
3940

4041
# Default values
41-
mysql_host='localhost';
42-
mysql_user='root';
43-
mysql_password='root';
44-
mysql_database="${wpconfig_site_id}";
45-
project_raw_domain="${wpconfig_site_id}.test";
42+
wputools__mysql_host='localhost';
43+
wputools__mysql_user='root';
44+
wputools__mysql_password='root';
45+
wputools__mysql_database="${wpconfig_site_id}";
46+
wputools__project_raw_domain="${wpconfig_site_id}.test";
47+
wputools__use_https='n';
48+
wputools__protocol='http';
4649

4750
wpconfig_default_settings=$(bashutilities_get_yn "- Use default settings? (localhost/root/root)" 'y');
4851
if [[ "${wpconfig_default_settings}" != 'y' ]];then
49-
mysql_host=$(bashutilities_get_user_var "- What is the MySQL host?" "localhost");
50-
mysql_user=$(bashutilities_get_user_var "- What is the MySQL user?" "root");
51-
mysql_password=$(bashutilities_get_user_var "- What is the MySQL password?" "root");
52-
mysql_database=$(bashutilities_get_user_var "- What is the MySQL database?" "${wpconfig_site_id}");
53-
project_raw_domain=$(bashutilities_get_user_var "- What is the project domain name?" "${wpconfig_site_id}.test");
52+
wputools__mysql_host=$(bashutilities_get_user_var "- What is the MySQL host?" "localhost");
53+
wputools__mysql_user=$(bashutilities_get_user_var "- What is the MySQL user?" "root");
54+
wputools__mysql_password=$(bashutilities_get_user_var "- What is the MySQL password?" "root");
55+
wputools__mysql_database=$(bashutilities_get_user_var "- What is the MySQL database?" "${wpconfig_site_id}");
56+
wputools__project_raw_domain=$(bashutilities_get_user_var "- What is the project domain name?" "${wpconfig_site_id}.test");
57+
wputools__use_https=$(bashutilities_get_yn "- Use HTTPS for site URL?" 'n');
58+
fi;
59+
60+
if [[ "${wputools__use_https}" == 'y' ]];then
61+
wputools__protocol='https';
5462
fi;
5563

5664
###################################
@@ -59,25 +67,22 @@ fi;
5967

6068
_WPCLICOMMAND core config \
6169
--skip-check \
62-
--dbhost="${mysql_host}" \
63-
--dbname="${mysql_database}" \
64-
--dbuser="${mysql_user}" \
65-
--dbpass="${mysql_password}" \
70+
--dbhost="${wputools__mysql_host}" \
71+
--dbname="${wputools__mysql_database}" \
72+
--dbuser="${wputools__mysql_user}" \
73+
--dbpass="${wputools__mysql_password}" \
6674
--dbprefix="${wpconfig_site_prefix}" \
6775
--extra-php <<PHP
6876
6977
# URLs
7078
if(!isset(\$_SERVER['HTTP_HOST']) || !\$_SERVER['HTTP_HOST']){
71-
\$_SERVER['HTTP_HOST'] = '${project_raw_domain}';
79+
\$_SERVER['HTTP_HOST'] = '${wputools__project_raw_domain}';
7280
}
7381
if(!isset(\$_SERVER['SERVER_PROTOCOL']) || !\$_SERVER['SERVER_PROTOCOL']){
7482
\$_SERVER['SERVER_PROTOCOL'] = 'HTTP/1.0';
7583
}
76-
define('WP_SITEURL', 'http://' . \$_SERVER['HTTP_HOST'] . '/');
77-
define('WP_HOME', 'http://' . \$_SERVER['HTTP_HOST'] . '/');
78-
79-
# Environment
80-
define('WP_ENVIRONMENT_TYPE', 'local');
84+
define('WP_SITEURL', '${wputools__protocol}://' . \$_SERVER['HTTP_HOST'] . '/');
85+
define('WP_HOME', '${wputools__protocol}://' . \$_SERVER['HTTP_HOST'] . '/');
8186
8287
# Block external access
8388
#define('WP_HTTP_BLOCK_EXTERNAL', true);

inc/stop.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,5 +190,12 @@ unset -v wputools_use_home_url;
190190
unset -v wputools_use_site_name;
191191
unset -v wputools_wpconfig_ask_overwrite;
192192
unset -v wputools_wp_config_path;
193+
unset -v wputools__mysql_host;
194+
unset -v wputools__mysql_user;
195+
unset -v wputools__mysql_password;
196+
unset -v wputools__mysql_database;
197+
unset -v wputools__project_raw_domain;
198+
unset -v wputools__protocol;
199+
unset -v wputools__use_https;
193200

194201
. "${_TOOLSDIR}BashUtilities/modules/stop.sh";

wputools.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
WPUTools(){
44

5-
local _WPUTOOLS_VERSION='0.141.3';
5+
local _WPUTOOLS_VERSION='0.141.4';
66
local _PHP_VERSIONS=(7.0 7.1 7.2 7.3 7.4 8.0 8.1 8.2 8.3 8.4 8.5 9.0)
77
local _PHP_VERSIONS_OBSOLETES=(7.0 7.1 7.2 7.3 7.4 8.0)
88
local _PHP_VERSIONS_ADVANCED=(8.3 8.4 8.5 9.0)

0 commit comments

Comments
 (0)