Skip to content

Instantly share code, notes, and snippets.

@eksiscloud
Last active May 14, 2025 05:38
Show Gist options
  • Save eksiscloud/8a131e993842e1edf0d735309fea5303 to your computer and use it in GitHub Desktop.
Save eksiscloud/8a131e993842e1edf0d735309fea5303 to your computer and use it in GitHub Desktop.
WP CLI + Bash: Batch installer of Wordpress plugins
#!/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 {} +
@eksiscloud
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment