Skip to content

Commit 2e3628b

Browse files
jakeparisJake Paris
andauthored
Bugfix for failure to include custom config in wp config, fixes #78 (#79)
Co-authored-by: Jake Paris <[email protected]>
1 parent 93b53eb commit 2e3628b

File tree

4 files changed

+25
-10
lines changed

4 files changed

+25
-10
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,9 @@ ddev exec npm run watch
134134

135135
### WordPress Configuration Changes
136136

137+
When this add-on is added to a WordPress project, DDEV's management of the installation files is turned
138+
off.
139+
137140
The changes this add-on makes to the `wp-config-ddev.php` file during installation can be seen below.
138141

139142
The `wp-config-ddev-browserync.php` file is included before the `/** WP_HOME URL */` comment.

install.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,23 @@ post_install_actions:
3434
#ddev-nodisplay
3535
#ddev-description:Install browsersync settings for WordPress if applicable
3636
scripts/setup-wordpress-settings.sh
37+
- |
38+
#ddev-nodisplay
39+
#ddev-description:Check for WordPress and disable ddev management of wp-config file
40+
if [[ $DDEV_PROJECT_TYPE = 'wordpress' ]]; then
41+
ddev config --disable-settings-management=true;
42+
fi
43+
3744
3845
removal_actions:
3946
- |
4047
#ddev-nodisplay
4148
#ddev-description:Remove browsersync settings for WordPress if applicable
4249
rm -f "${DDEV_APPROOT}/wp-config-ddev-browsersync.php"
4350
scripts/remove-wordpress-settings.sh
51+
# Don't automatically renable settings management in case user didn't have it enabled in the first place
52+
- |
53+
if [[ $DDEV_PROJECT_TYPE = 'wordpress' ]]; then
54+
echo "Note: You may wish to renable ddev's management of the wp-config file:"
55+
echo " Run 'ddev config --disable-settings-management=false && ddev restart'"
56+
fi

scripts/remove-wordpress-settings.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ then
77
exit 0
88
fi
99

10-
if ( ddev debug configyaml 2>/dev/null | grep 'disable_settings_management:\s*true' >/dev/null 2>&1 ) ; then
11-
exit 0
12-
fi
10+
# if ( ddev debug configyaml 2>/dev/null | grep 'disable_settings_management:\s*true' >/dev/null 2>&1 ) ; then
11+
# exit 0
12+
# fi
1313

1414
SETTINGS_FILE_NAME="${DDEV_APPROOT}/wp-config.php"
1515

scripts/setup-wordpress-settings.sh

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ then
77
exit 0
88
fi
99

10-
if ( ddev debug configyaml 2>/dev/null | grep 'disable_settings_management:\s*true' >/dev/null 2>&1 ) ; then
11-
exit 0
12-
fi
10+
# if ( ddev debug configyaml 2>/dev/null | grep 'disable_settings_management:\s*true' >/dev/null 2>&1 ) ; then
11+
# exit 0
12+
# fi
1313

1414
cp scripts/wp-config-ddev-browsersync.php $DDEV_APPROOT/
1515

@@ -23,18 +23,17 @@ if grep -q "/\*\* Include for ddev-browsersync to modify WP_HOME and WP_SITEURL.
2323
fi
2424

2525
echo "Adding wp-config-ddev-browsersync.php to: ${SETTINGS_FILE_NAME}"
26-
26+
2727
# Append our code before the ddev config comment.
2828
awk '
29-
/\/\/ Include for ddev-managed settings in wp-config-ddev.php./ {
29+
/\/\/ Include for settings managed by ddev./ {
3030
print "/** Include for ddev-browsersync to modify WP_HOME and WP_SITEURL. */"
3131
print "$ddev_browsersync_settings = dirname( __FILE__ ) . \"/wp-config-ddev-browsersync.php\";"
32-
print ""
3332
print "if ( is_readable( $ddev_browsersync_settings ) ) {"
3433
print " require_once( $ddev_browsersync_settings );"
3534
print "}"
3635
print ""
37-
print "// Include for ddev-managed settings in wp-config-ddev.php."
36+
print "// Include for settings managed by ddev."
3837
next
3938
}
4039
{print}

0 commit comments

Comments
 (0)