Description
The activate_theme() function in wordpress-local.sh doesn't check whether the specified theme directory exists before attempting activation. This leads to confusing Docker/WP-CLI errors when a user mistypes a theme name.
Current Behavior
./wordpress-local.sh activate-theme typo-theme
# Outputs a confusing WP-CLI error from inside Docker
Expected Behavior
./wordpress-local.sh activate-theme typo-theme
# Error: Theme not found: themes/typo-theme
# Available themes:
# flavian
Task
Add a directory existence check in the activate_theme() function before calling Docker.
Suggested Fix (around line 141)
activate_theme() {
local theme_slug="$1"
if [ -z "$theme_slug" ]; then
print_error "Usage: ./wordpress-local.sh activate-theme <theme-slug>"
echo ""
echo "Available themes:"
ls -1 themes/
exit 1
fi
# Add this validation:
if [ ! -d "themes/$theme_slug" ]; then
print_error "Theme not found: themes/$theme_slug"
echo ""
echo "Available themes:"
ls -1 themes/
exit 1
fi
docker-compose exec wordpress wp theme activate "$theme_slug" --allow-root
}
Files to Edit
wordpress-local.sh — activate_theme() function (around line 141)
Acceptance Criteria
Description
The
activate_theme()function inwordpress-local.shdoesn't check whether the specified theme directory exists before attempting activation. This leads to confusing Docker/WP-CLI errors when a user mistypes a theme name.Current Behavior
./wordpress-local.sh activate-theme typo-theme # Outputs a confusing WP-CLI error from inside DockerExpected Behavior
Task
Add a directory existence check in the
activate_theme()function before calling Docker.Suggested Fix (around line 141)
Files to Edit
wordpress-local.sh—activate_theme()function (around line 141)Acceptance Criteria
print_errorfunction consistent with rest of script