Fix bug edits
parent
df2eef248e
commit
c7668bee46
|
|
@ -249,14 +249,22 @@ sed -i -E "s|define\([[:space:]]*['\"]WP_HOME['\"][[:space:]]*,[[:space:]]*['\"]
|
||||||
|
|
||||||
if [[ $needs_home -eq 1 || $needs_siteurl -eq 1 || $needs_http_host -eq 1 ]]; then
|
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) …"
|
info "Inserting missing wp-config.php directives (WP_HOME/WP_SITEURL/HTTP_HOST) …"
|
||||||
awk -v url="$TARGET_URL" -v host="$HOST_ONLY" -v insert_home="$needs_home" -v insert_siteurl="$needs_siteurl" -v insert_hostfix="$needs_http_host" '
|
INSERT_BLOCK="\n// Added by wp-search-replace.sh\n"
|
||||||
|
if [[ $needs_home -eq 1 ]]; then
|
||||||
|
INSERT_BLOCK+="define( 'WP_HOME', '${TARGET_URL}' );\n"
|
||||||
|
fi
|
||||||
|
if [[ $needs_siteurl -eq 1 ]]; then
|
||||||
|
INSERT_BLOCK+="define( 'WP_SITEURL', '${TARGET_URL}' );\n"
|
||||||
|
fi
|
||||||
|
if [[ $needs_http_host -eq 1 ]]; then
|
||||||
|
INSERT_BLOCK+="if ( defined( 'WP_CLI' ) && WP_CLI && ! isset( $_SERVER['HTTP_HOST'] ) ) { $_SERVER['HTTP_HOST'] = '${HOST_ONLY}'; }\n"
|
||||||
|
fi
|
||||||
|
|
||||||
|
awk -v block="$INSERT_BLOCK" '
|
||||||
BEGIN { inserted=0 }
|
BEGIN { inserted=0 }
|
||||||
/\/\* That\x27s all/{
|
/\/\* That/ {
|
||||||
print "\n// Added by wp-search-replace.sh";
|
printf "%s", block
|
||||||
if (insert_home == 1) print "define( \"WP_HOME\", \"" url "\" );";
|
inserted=1
|
||||||
if (insert_siteurl == 1) print "define( \"WP_SITEURL\", \"" url "\" );";
|
|
||||||
if (insert_hostfix == 1) print "if ( defined( \"WP_CLI\" ) && WP_CLI && ! isset( $_SERVER[\"HTTP_HOST\"] ) ) { $_SERVER[\"HTTP_HOST\"] = \"" host "\"; }";
|
|
||||||
inserted=1;
|
|
||||||
}
|
}
|
||||||
{ print }
|
{ print }
|
||||||
END { if (!inserted) exit 1 }
|
END { if (!inserted) exit 1 }
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue