So I can cache a WordPress installation with:
wp core download --version=4.5 --path=/tmp/wp45
Subsequent requests of version 4.5 will be pulled from wp-cli
local cache.
I think that:
wp plugin install query-monitor
will also be cached, but the command only works after a successful wordpress installation (e.g. after database setup, config file setup, wp install).
Is there a way to pre-cache plugins, just like a wp core download
with out having to do the setup?
So I can cache a WordPress installation with:
wp core download --version=4.5 --path=/tmp/wp45
Subsequent requests of version 4.5 will be pulled from wp-cli
local cache.
I think that:
wp plugin install query-monitor
will also be cached, but the command only works after a successful wordpress installation (e.g. after database setup, config file setup, wp install).
Is there a way to pre-cache plugins, just like a wp core download
with out having to do the setup?
1 Answer
Reset to default 3WP CLI already caches things without needing to use wp core download
, that's why your wp core download
command works. You can skip the extraction step entirely by just downloading WP directly into its cache folder, as well as any plugins
By default WP CLI will store any files it requests via HTTP in ~/.wp-cli/cache
, that includes plugins and themes:
vagrant@vvv:/srv/www/wordpress-three/public_html$ wp plugin install wordpress-seo
Installing Yoast SEO (11.9)
Downloading installation package from https://downloads.wordpress/plugin/wordpress-seo.11.9.zip...
Unpacking the package...
Installing the plugin...
Plugin installed successfully.
Success: Installed 1 of 1 plugins.
vagrant@vvv:/srv/www/wordpress-three/public_html$ ls -al ~/.wp-cli/cache/
core/ plugin/
vagrant@vvv:/srv/www/wordpress-three/public_html$ ls -al ~/.wp-cli/cache/plugin/
total 3592
drwxrwxr-x 2 vagrant vagrant 4096 Aug 28 12:44 .
drwxr-xr-x 4 vagrant vagrant 4096 Aug 28 12:44 ..
-rw-rw-r-- 1 vagrant vagrant 3666701 Aug 28 12:44 wordpress-seo-11.9.zip
vagrant@vvv:/srv/www/wordpress-three/public_html$
So if I did this:
mkdir -p ~/.wp-cli/cache/plugin
wget https://downloads.wordpress/plugin/wordpress-seo.11.9.zip ~/.wp-cli/cache/plugin/wordpress-seo-11.9.zip
Then that would have the same effect, as would dropping wordpress-5.2.2-en_US.tar.gz
in ~/.wp-cli/cache/core
Notice also that the filename WP CLI uses has -
hyphens rather than the .
that uses. Compare wordpress-seo.11.9.zip
with wordpress-seo-11.9.zip
As for how to do it entirely with WP CLI, you would have to create a temporary WP install then change into it and install the plugin there, but it's easier to just download without extracting