Fix bug edits
parent
0ad8e72652
commit
df2eef248e
|
|
@ -233,9 +233,19 @@ if [[ -f "$CONFIG_FILE" && -w "$CONFIG_FILE" ]]; then
|
|||
sed -i -E "s|define\([[:space:]]*['\"]WP_HOME['\"][[:space:]]*,[[:space:]]*['\"][^'\"]*['\"][[:space:]]*\);|define( 'WP_HOME', '${TARGET_URL}' );|; s|define\([[:space:]]*['\"]WP_SITEURL['\"][[:space:]]*,[[:space:]]*['\"][^'\"]*['\"][[:space:]]*\);|define( 'WP_SITEURL', '${TARGET_URL}' );|; s|\$_SERVER\[(\"|')HTTP_HOST\1\][[:space:]]*=[[:space:]]*(\"|')[^"']*\2;|\$_SERVER['HTTP_HOST'] = '${HOST_ONLY}';|" "$CONFIG_FILE" || warning "Failed to update wp-config.php"
|
||||
|
||||
# Determine which entries are missing to avoid duplicates
|
||||
needs_home=1; grep -Eq "define\([[:space:]]*['\"]WP_HOME['\"]" "$CONFIG_FILE" && needs_home=0 || true
|
||||
needs_siteurl=1; grep -Eq "define\([[:space:]]*['\"]WP_SITEURL['\"]" "$CONFIG_FILE" && needs_siteurl=0 || true
|
||||
needs_http_host=1; grep -Eq "\$_SERVER\[(\"|')HTTP_HOST\1\][[:space:]]*=" "$CONFIG_FILE" && needs_http_host=0 || true
|
||||
needs_home=1
|
||||
needs_siteurl=1
|
||||
needs_http_host=1
|
||||
|
||||
if grep -Eq "define[[:space:]]*\([[:space:]]*['\"]WP_HOME['\"]" "$CONFIG_FILE"; then
|
||||
needs_home=0
|
||||
fi
|
||||
if grep -Eq "define[[:space:]]*\([[:space:]]*['\"]WP_SITEURL['\"]" "$CONFIG_FILE"; then
|
||||
needs_siteurl=0
|
||||
fi
|
||||
if grep -Eq "\$_SERVER\[(\"|')HTTP_HOST\1\][[:space:]]*=" "$CONFIG_FILE"; then
|
||||
needs_http_host=0
|
||||
fi
|
||||
|
||||
if [[ $needs_home -eq 1 || $needs_siteurl -eq 1 || $needs_http_host -eq 1 ]]; then
|
||||
info "Inserting missing wp-config.php directives (WP_HOME/WP_SITEURL/HTTP_HOST) …"
|
||||
|
|
|
|||
Loading…
Reference in New Issue