最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

wp cli - Is there a way to pre-cache plugins with WP-CLI for faster installation?

programmeradmin0浏览0评论

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?

Share Improve this question edited Dec 16, 2019 at 3:10 butlerblog 5,1213 gold badges28 silver badges44 bronze badges asked Aug 28, 2019 at 12:13 farinspacefarinspace 4802 silver badges10 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 3

WP 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

发布评论

评论列表(0)

  1. 暂无评论