wp-cli & Shell Command Library
The WordPress command line interface makes the work we do easy. This page also contains shell script commands that do not use wp-cli but are run the same way.
Commands
Media Library
Delete Gravity Forms file uploads
Deletes all files uploaded with form submissions. Frees disk space in local copies of sites.
rm -rf wp-content/uploads/gravity_forms/*
Multisite
Activate Plugin on Every Site
wp site list --field=url | xargs -n1 -I % wp --url=% plugin activate wp-api-disable-user-list/wp-api-disable-user-list.php
Find Sites Using a Specific Plugin
Reveals which blogs in a network have activated a specific plugin.
sites=$(wp site list --field=url)
for url in $sites; do
if wp plugin is-active "embed-pdf-gravityforms/embed-pdf-gravityforms.php" --url="${url}" --network; then
echo "${url}"
fi
done
Grant Super Admin to User
wp super-admin add [email protected]
Network-wide Search and Replace
Runs the wp search-replace
command on every site in a network.
wp site list --field=url | xargs -n1 -I % wp --url=% search-replace '[vehicle_form_field]' '[invp_vehicle vehicle]'
Plugins
Activate Plugins According to the Option
Syncs the plugin directory to the database option. Installs and activates plugins using the list stored in the site.
wp plugin list --status=active --field=file | xargs -n1 -I % wp plugin install % -–activate
Users
Change User Password
wp user update [email protected] --user_pass="h43v#sdsfg)fgh49gh@cY<3Tb4Wfk9ke"