Last active
May 14, 2025 05:38
-
-
Save eksiscloud/8a131e993842e1edf0d735309fea5303 to your computer and use it in GitHub Desktop.
WP CLI + Bash: Batch installer of Wordpress plugins
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
## WordPress Plugin Installer using BASH and WP-CLI | |
# Make executable: chmod u+x wp-plugins | |
# remember change WPPATH | |
# array of plugin slugs to install | |
WPPLUGINS=( | |
activitypub advanced-database-cleaner categorytinymce classic-editor code-snippets change-last-modified-date disable-gutenberg \ | |
easy-google-adsense easy-table-of-contents ewww-image-optimizer footnotes-made-easy header-footer loco-translate \ | |
relevanssi seo-by-rank-math simple-pull-quote tablepress tinymce-advanced updraftplus webfinger wp-crontrol wp-ses | |
) | |
# path to WordPress | |
WPPATH=/var/www/html | |
#loop through array, install and activate the plugins | |
for WPPLUGIN in "${WPPLUGINS[@]}"; do | |
#check if plugin is installed, sets exit status to 1 if not found | |
wp plugin is-installed $WPPLUGIN --path=$WPPATH --allow-root | |
#install plugin if not present based on exit code value | |
if [ $? -eq 1 ]; then | |
wp plugin install $WPPLUGIN --activate --path=$WPPATH --allow-root | |
fi | |
done | |
# Fix permissions | |
sudo chown -R www-data:www-data $WPPATH | |
sudo find $WPPATH -type f -exec chmod 644 {} + | |
sudo find $WPPATH -type d -exec chmod 755 {} + |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
After some googling this must be the original script: https://guides.wp-bullet.com/batch-install-wordpress-plugins-using-wp-cli-bash-script/