How to use WP-CLI with the Security plugin
WP-CLI is a command-line tool for WordPress development and administrative tasks. It provides commands to manage the CleanTalk Security plugin efficiently without accessing the WordPress dashboard.
Requirements
- Install the latest version of the WP-CLI tool on your server.
- Install our Security plugin (version 2.156 or later).
- Alternative plugin installation method (useful for multiple sites with similar content)
- Unzip the plugin into wp-content/plugins/.
- Run this command from the WordPress root directory:
wp plugin install security-malware-firewall --activate
This could be useful if you have a lot of sites with the same basic content.
Note: If CLI alias commands don’t work after installation, use php wp-cli.phar instead of wp:
php wp-cli.phar plugin install security-malware-firewall --activate
How to use
1. List Available Commands
Run:
wp spbc
Output:
usage: wp spbc create
or: wp spbc settings
or: wp spbc template
or: wp spbc malware_scanner
For detailed help, use:
wp help spbc <command>
2. Service Setup Command
The command will run automatic service creation, then run synchronization with the cloud data, including account details, Firewall rules, scanner signatures e.t.c.
Note, to run automatic service getting, you should set the Policy state in the CleanTalk dashboard, by defaults the feature is enabled with user token provided (is set to Auto).
wp spbc create --token=your_token --domain=sitename.com
Required Arguments:
--token => User Token from https://cleantalk.org/my/profile
--domain => Host domain of your website
3. Plugin settings commands
Change plugin settings using %setting%=Off|On syntax.
Example - disable the Firewall
wp spbc settings --firewall__firewall_enabled=off
Example - enable the Firewall
wp spbc settings --firewall__firewall_enabled=on
Required params and style:
%option_name%=Off | On => The name of the setting you want to change and it's new state.
// Malware scanner settings
scanner__auto_start_enabled => Automatic start of scanner
scanner__heuristic_analysis_enabled => Heuristic analysis enabled
scanner__signature_analysis_enabled => Signature analysis enabled
scanner__automatic_cure_enabled => Automatic cure enabled
scanner__os_cron_analysis_enabled => Operating system cron analysis enabled
scanner__unknown_files_listing_enabled => Unknown files listing enabled
// Filesystem watcher setting
scanner__fs_watcher => Filesystem watcher feature enabled
// Firewall settings
firewall__firewall_enabled => Global state for all firewall features
firewall__traffic_control_enabled => Traffic control enabled
firewall__waf_enabled => Web Application Firewall enabled
firewall__waf_blocker_enabled => Web Application Firewall blocker enabled
// Vulnerability check module settings
vulnerability_check__cron_enabled => Vulnerability check is started by cron
vulnerability_check__reports_enabled => Vulnerability check reports enabled
vulnerability_check__testing_before_install_enabled => Vulnerability check before installation enabled
vulnerability_check__warn_on_modules_pages_enabled => Vulnerability check warning on modules pages enabled
// WordPress features
wpsec__xmlrpc_disabled => Disable XML-RPC access
wpsec__rest_api_for_non_authenticated_disabled => Restrict REST API access for non-authenticated users
// Other settings
admin_bar__enabled => Security admin bar enabled
dashboard_widget__enabled => Security dashboard widget enabled
complete_deactivation_enabled => Complete deactivation of the plugin, if set all the data will be removed from the database after deactivation
2fa__enabled => Two factor authentication - can be set only to Off, use this option to force disable 2FA
login_page__rename_enabled => Renaming of login page - can be set only to Off, use this option to force disable renaming of the login page
4. Settings templates commands
Apply pre-saved settings templates (requires Extra Package )
- Get a list of available templates.
wp spbc template list
- Set an existing template.
wp spbc template set --id=template_id
Required Arguments:
--id - Template ID, the ID can be obtained from list command
- Reset settings to defaults.
wp spbc template set reset
5. Malware scanner commands
These commands allow to run some service actions for the Malware Scanner.
- Run Malware scanner in the background mode. The scan process will start after 30 seconds and will use less sources than manual run from the plugin interface. Please note, the background scan takes a lot of time and has no option to see the results from the CLI. To find out the results, enter the plugin settings or check your CleanTalk dashboard after 2 hours since starting.
wp spbc malware_scanner start
- Clear all the scan results. Usefull if something goes wrong.
wp spbc malware_scanner clear_results
- Update the scanner signatures for Signatures Analysis feature. Usefull if something goes wrong.
wp spbc malware_scanner update_signatures
If you haven't found the answer to your question or if you want to request new features for CLI, please, contact our support team.
It would also be interesting
- How To Update Universal Security Extension UniForce By CleanTalkImportant note Starting from November 1, 2024, the Uniforce Universal Security active development has...
- How To Install Universal Security Extension UniForce By CleanTalkImportant note Starting from November 1, 2024, the Uniforce Universal Security active development has...
- All Installation Manuals of CleanTalk Anti-Spam ServiceCleanTalk Anti-Spam Installation Guides Here you can find our plugin installation guides for popular...