Documentation

WP-CLI Integration for Automated Configuration and Server Management

Posted in: Getting Started (4) How To (18) Plugin Options Explained (42) Actions / Filters (35)      Options (33)    Code Example (20)  

Managing WP Hide PRO through the WordPress dashboard is convenient, but advanced WordPress environments often require something more: automation, repeatability, scripting, and the ability to manage multiple servers consistently.

With the new WP-CLI integration for WP Hide PRO, administrators and developers can now manage important plugin operations directly from the command line. This makes WP Hide PRO easier to integrate into deployment workflows, server maintenance scripts, staging environments, and large WordPress installations.

Available WP-CLI Commands

The WP Hide PRO WP-CLI integration provides commands for managing configuration, server rules, caching, validation, and plugin status:

wp wp-hide import <file> <server>
wp wp-hide rebuild <server>
wp wp-hide rules show <server>
wp wp-hide status
wp wp-hide export <file>
wp wp-hide validate <file>
wp wp-hide cache clear
wp wp-hide config validate <file>
wp wp-hide config diff <file>
wp wp-hide reset options <server> --yes

The supported server types are:

apache
litespeed
nginx
iis

These commands make it possible to manage WP Hide PRO without relying exclusively on the WordPress administration interface.

Import WP Hide PRO settings from the command line

One of the most useful additions is the ability to import a complete WP Hide PRO configuration from a JSON file.

wp wp-hide import /secure/configs/wp-hide.json nginx

The <server-type> parameter can be apache, litespeed, nginx, or iis.

This makes it possible to prepare a WP Hide PRO configuration once and deploy it to multiple environments without manually reproducing every setting through the WordPress dashboard.

For automated deployments, the import command also supports a dry run:

wp wp-hide import /secure/configs/wp-hide.json nginx --dry-run

Dry-run mode validates the configuration and shows the expected rules without changing the current settings. This is particularly useful when deploying a configuration across a fleet of WordPress websites.

Rebuild WP Hide PRO rules

The rebuild command regenerates the WP Hide PRO rules and environment data without importing a new configuration.

wp wp-hide rebuild litespeed

This can be useful after a plugin update, a server configuration change, or when rewrite files have been damaged or modified externally.

For example:

wp wp-hide rebuild apache

The rebuild process restores the generated environment based on the existing WP Hide PRO settings.

View generated server rules

The rules show command allows administrators to inspect the rules generated by WP Hide PRO without changing the server configuration.

wp wp-hide rules show nginx

This is especially useful for Nginx, where rewrite rules cannot always be deployed automatically by a WordPress plugin.

In this situation, WP Hide PRO outputs the generated Nginx configuration directly in the terminal. The administrator can then copy the output and add it to the appropriate Nginx server configuration file.

The same approach can be used to inspect Apache or IIS rules:

wp wp-hide rules show apache
wp wp-hide rules show iis

This provides an easy way to verify exactly what WP Hide PRO expects to be configured at the web-server level.

Check WP Hide PRO status

The status command provides an overview of the current WP Hide PRO environment.

wp wp-hide status --server=litespeed

For automation and monitoring systems, the result can also be returned as JSON:

wp wp-hide status --server=nginx --format=json

The status information can include the installed WP Hide PRO version, detected or selected server type, cache information, rewrite target, manual-deployment state, and whether the generated rules are currently applied.

Because JSON output is available, the command can also be consumed by deployment scripts, monitoring tools, or custom server-management systems.

Export WP Hide PRO configuration

WP Hide PRO settings can be exported into a JSON file using:

wp wp-hide export /secure/configs/wp-hide.json

If the destination file already exists, use --force:

wp wp-hide export /secure/configs/wp-hide.json --force

The exporter prepares the configuration specifically for migration and deployment. As a security precaution, certain administrator/login blocking options are deliberately reset to no in exported configurations. This helps prevent a migrated configuration from unintentionally locking administrators out of a new environment.

The exported JSON file can then be stored securely and imported into another WordPress installation.

Validate and compare configurations

Before importing a configuration, administrators can validate an exported file:

wp wp-hide validate /secure/configs/wp-hide.json

WP Hide PRO also provides configuration validation and comparison functionality for migration workflows:

wp wp-hide config validate /secure/configs/wp-hide.json
wp wp-hide config diff /secure/configs/wp-hide.json

The diff operation makes it possible to review the expected configuration changes before applying them, which is particularly valuable when managing production websites.

Clear WP Hide PRO cache

The cache can also be cleared directly from WP-CLI:

wp wp-hide cache clear

This calls the internal WP Hide PRO cache-clearing mechanism and can also trigger supported cache-plugin purge operations.

Cache maintenance can therefore become part of an automated deployment script instead of requiring a manual visit to the WordPress dashboard.

Reset WP Hide PRO options

For environments where the existing configuration needs to be removed, WP Hide PRO provides an explicit reset operation:

wp wp-hide reset options --yes

The server type can also be specified:

wp wp-hide reset options litespeed --yes
wp wp-hide reset options nginx --yes

The --yes parameter confirms the operation so it can safely be used in scripts and automated processes.

Built for automation and large-scale deployments

The new WP-CLI integration is particularly useful for agencies, developers, hosting providers, and administrators managing multiple WordPress installations.

A typical deployment workflow can now be entirely command-line driven:

wp wp-hide export /secure/configs/wp-hide.json --force
wp wp-hide config validate /secure/configs/wp-hide.json
wp wp-hide import /secure/configs/wp-hide.json nginx --dry-run
wp wp-hide import /secure/configs/wp-hide.json nginx
wp wp-hide rebuild nginx
wp wp-hide cache clear
wp wp-hide status --server=nginx --format=json

This approach makes WP Hide PRO configuration easier to reproduce, audit, version, and deploy across staging and production environments.

The new WP-CLI integration extends WP Hide PRO beyond the WordPress dashboard and makes its configuration and server-management capabilities accessible to modern DevOps workflows. Whether you are managing one production website or hundreds of WordPress installations, WP-CLI provides a faster and more reliable way to keep WP Hide PRO configurations consistent.

Share on FacebookShare on Google+Tweet about this on TwitterShare on LinkedIn
Scroll to top