woocommerce-paypal-payments/.ddev/commands/web/wp-reset
Emili Castells Guasch ba3fbf549d
Some checks failed
CI / PHP 7.4 (push) Has been cancelled
CI / PHP 8.0 (push) Has been cancelled
CI / PHP 8.1 (push) Has been cancelled
CI / PHP 8.2 (push) Has been cancelled
CI / PHP 8.3 (push) Has been cancelled
CI / PHP 8.4 (push) Has been cancelled
PR Playground Demo / prepare_version (push) Has been cancelled
PR Playground Demo / build_plugin (push) Has been cancelled
PR Playground Demo / create_archive (push) Has been cancelled
PR Playground Demo / Comment on PR with Playground details (push) Has been cancelled
Add url constant
2025-09-01 16:27:56 +02:00

62 lines
1.2 KiB
Bash
Executable file

#!/bin/bash
show-help() {
echo -e "\nReset the WordPress database and reinstall WordPress"
echo -e "\tExample: ddev wp-reset"
echo -e "\nRemove all plugins --clean-plugins"
echo -e "\tExample: ddev wp-reset --clean-plugins\n"
}
remove-plugins() {
echo "Deactivating all plugins..."
wp plugin deactivate --all --path=.ddev/wordpress
echo "Deleting all plugins..."
wp plugin delete --all --path=.ddev/wordpress
}
reset-database() {
echo "Resetting database..."
wp db reset --yes --path=.ddev/wordpress
if [ "$1" = "clean-plugins" ]; then
remove-plugins
fi
echo "Installing WordPress..."
wp core install \
--url="${DDEV_PRIMARY_URL}" \
--title="${WP_TITLE}" \
--admin_user="${ADMIN_USER}" \
--admin_password="${ADMIN_PASS}" \
--admin_email="${ADMIN_EMAIL}" \
--path=.ddev/wordpress
echo "Database reset and WordPress installation completed!"
}
clean_plugins=false
while [[ $# -gt 0 ]]; do
case $1 in
--clean-plugins)
clean_plugins=true
shift
;;
-h|--help)
show-help
exit 0
;;
*)
echo "Unknown option: $1"
show-help
exit 1
;;
esac
done
if [ "$clean_plugins" = true ]; then
reset-database "clean-plugins"
else
reset-database
fi