Rate this article :
This article was useful to you ?
Yes
No
Vous avez noté 0 étoile(s)
Procédure
The WP-CLI is a tool available from a Terminal that allows you to manage your WordPress site simply, without having to connect to your site. It is available free of charge on all the shared hosting packages offered by LWS and is very easy to use: even a novice can use it. Install plugins, update your site, manage multiple sites... All these actions are available with just a few commands.
Since version 3.3, LWS Optimize, the all-in-one plugin developed by LWS for caching pages, optimising images and lazy-loading elements on your WordPress site, has offered a range of commands using the WP-CLI for quick and easy control of the plugin's various functions.
Good news! If you already have version 3.3 or later of LWS Optimize installed on your site, then you already have access to the CLI commands. If you don't already have the LWS Optimize plugin, follow our documentation to learn how to install and configure it.
If the plugin installed on your site is not up to date, which you can check by going to "Extensions" from your WordPress dashboard, simply click on "update now" to proceed with the update.
At present, the CLI is able to perform various actions on 7 different elements:
All LWSOptimize commands start in the same way: "wp lwsoptimize" followed by the element to be modified and then the action to be performed. For example: "wp lwsoptimize filecache deactivate" will deactivate the file cache on the target site. Some commands, particularly those returning data, accept the --format=json (or --json) argument, which returns the result of the command in JSON format, useful for integrating WP-CLI into your code.
To manage the state of the cache, you can use the command :
wp lwsoptimize filecache activate|deactivate
Where activate activates the cache and deactivate deactivates it. If the cache is already in the selected state, you will be warned that no further action has been taken.
You can also display a summary of the state of the cache, its status, using the command :
wp lwsoptimize filecache status [--json]
Depending on whether you add --json or not, the return will be displayed differently. In all cases, you will find the same information: the state of the cache and its contents at the time the command is run.
Finally, and quite logically, there is a command that allows you to delete the entire file cache immediately:
wp lwsoptimize filecache clear
In a similar way to the file cache, you can manage the state of the preload using the command :
wp lwsoptimize preload activate|deactivate [number]
The parameter activate enables it, while deactivate disables it. When you activate preloading, you can specify a number (between 1 and 30) of pages to be preloaded each time the cron is run. If no value is entered or if it is invalid, 3 pages will be preloaded by default.
If you did not specify the number of pages to be preloaded when you activated preloading, or if you wish to change it, you can use the following command to change this value:
wp lwsoptimize preload change_amount {number}
To monitor the progress of preloading, use the command :
wp lwsoptimize preload status [--json]
As with the file cache, depending on whether you add --json or not, the result will be returned differently. In any case, you will get the status of the cache and its preloading, as well as the number of pages to be processed and the next cron occurrence.
If you only want to retrieve the next cron occurrence, you can also use the following command:
wp lwsoptimize preload next [--json]
To check the status of the Memcached service, use the command :
wp lwsoptimize memcached status [--json]
In addition to the operating status of Memcached, if the Memcached module is disabled (as may be the case on cPanel), this will be indicated and if Redis is already active, you will be informed, due to the incompatibility between the 2.
The only other option available for Memcached is to manage the state of the module, using this command :
wp lwsoptimize memcached activate|deactivate
The activate parameter activates the module, while deactivate deactivates it.
To check the status of the automatic purge, use the command :
wp lwsoptimize autopurge status [--json]
You can also activate or deactivate autopurge, making your site completely static, with the command: wp lwsoptimize autopurge status [--json]:
wp lwsoptimize autopurge activate|deactivate
The activate parameter activates autopurge, while deactivate deactivates it.
The only action that can be taken on the file cache from the WP-CLI is to clear the cache, using the command :
wp lwsoptimize servercache clear
This category allows you to manage the LwsOptimize plugin directly, such as its status, using the command :
wp lwsoptimize configuration activate|deactivate {seconds}
The activate parameter activates the plugin, while deactivate deactivates it. The {seconds} parameter is used when deactivating, to choose how long the plugin should remain deactivated: 300s, 1800s, 3600s, 86400s. By default, if no argument is passed, the plugin is deactivated for 300 seconds.
It is also possible to change the plugin configuration between the 3 predefined configurations: basic, advanced and complete, which correspond to those available in the plugin options, using the command :
wp lwsoptimize configuration basic|advanced|complete
PageSpeed, Google's service for testing the speed and performance of your website, is available directly from LWSOptimize and in WP-CLI with the command :
wp lwsoptimize pagespeed
You will then get the main results (score and loading speed) returned by PageSpeed for the PC and Mobile versions of your site. By adding --json, you will receive a machine-readable version of this information:
You now know how to :
🚀 Thanks to this powerful tool, you can now optimise your WordPress site quickly and efficiently, with just a few commands! 🛠️
Many thanks for reading! 🙏 Don't hesitate to share your experiences or ask your questions by leaving a comment below. Your feedback is invaluable in helping us improve our services. 💬
Rate this article :
This article was useful to you ?
Yes
No
0mn reading
How can I minimize the files on my WordPress site with LWS Optimize?
0mn reading
How can I combine the files on my WordPress site with LWS Optimize?
0mn reading
How do I preload CSS files on my WordPress site with LWS Optimize?
0mn reading
How do I disable WordPress emojis with LWS Optimize?