wp-cli /core-command
下载、安装、更新和管理WordPress安装。
Requires
- composer/semver: ^1.4 || ^2 || ^3
- wp-cli/wp-cli: ^2.5.1
Requires (Dev)
- wp-cli/checksum-command: ^1 || ^2
- wp-cli/db-command: ^1.3 || ^2
- wp-cli/entity-command: ^1.3 || ^2
- wp-cli/extension-command: ^1.2 || ^2
- wp-cli/wp-cli-tests: ^4
- dev-main / 2.x-dev
- v2.1.18
- v2.1.17
- v2.1.16
- v2.1.15
- v2.1.14
- v2.1.13
- v2.1.12
- v2.1.11
- v2.1.10
- v2.1.9
- v2.1.8
- v2.1.7
- v2.1.6
- v2.1.5
- v2.1.4
- v2.1.3
- v2.1.2
- v2.1.1
- v2.1.0
- v2.0.13
- v2.0.12
- v2.0.11
- v2.0.10
- v2.0.9
- v2.0.8
- v2.0.7
- v2.0.6
- v2.0.5
- v2.0.4
- v2.0.3
- v2.0.2
- v2.0.1
- v2.0.0
- v1.0.12
- v1.0.11
- v1.0.10
- v1.0.9
- v1.0.8
- v1.0.7
- v1.0.6
- v1.0.5
- v1.0.4
- v1.0.3
- v1.0.2
- v1.0.1
- v1.0.0
- dev-add/feature-lint
- dev-fix/disable-auto-update-test
- dev-fix/mark-test-broken
- dev-fix/use-version-range-for-tests-dependency
- dev-enforce-php74-compat
- dev-h1-comwrg-poc
- dev-revert-140-lock-framework-to-2-4-0
- dev-108-add-core-release-command
- dev-v2-prep
This package is auto-updated.
Last update: 2024-09-14 11:21:26 UTC
README
下载、安装、更新和管理WordPress安装。
使用
此包实现了以下命令
wp core
下载、安装、更新和管理WordPress安装。
wp core
示例
# Download WordPress core
$ wp core download --locale=nl_NL
Downloading WordPress 4.5.2 (nl_NL)...
md5 hash verified: c5366d05b521831dd0b29dfc386e56a5
Success: WordPress downloaded.
# Install WordPress
$ wp core install --url=example.com --title=Example --admin_user=supervisor --admin_password=strongpassword [email protected]
Success: WordPress installed successfully.
# Display the WordPress version
$ wp core version
4.5.2
wp core check-update
通过版本检查API检查WordPress更新。
wp core check-update [--minor] [--major] [--force-check] [--field=<field>] [--fields=<fields>] [--format=<format>]
列出可用的最新版本,或者当已是最新版本时显示成功消息。
选项
[--minor]
Compare only the first two parts of the version number.
[--major]
Compare only the first part of the version number.
[--force-check]
Bypass the transient cache and force a fresh update check.
[--field=<field>]
Prints the value of a single field for each update.
[--fields=<fields>]
Limit the output to specific object fields. Defaults to version,update_type,package_url.
[--format=<format>]
Render output in a particular format.
---
default: table
options:
- table
- csv
- count
- json
- yaml
---
示例
$ wp core check-update
+---------+-------------+-------------------------------------------------------------+
| version | update_type | package_url |
+---------+-------------+-------------------------------------------------------------+
| 4.5.2 | major | https://downloads.wordpress.org/release/wordpress-4.5.2.zip |
+---------+-------------+-------------------------------------------------------------+
wp core download
下载核心WordPress文件。
wp core download [<download-url>] [--path=<path>] [--locale=<locale>] [--version=<version>] [--skip-content] [--force] [--insecure] [--extract]
将WordPress核心文件下载并解压到指定路径。如果没有指定路径,则使用当前目录。下载的构建将验证md5值是否正确,然后缓存在本地文件系统。后续使用命令时,如果本地缓存仍然存在,则将使用本地缓存。
选项
[<download-url>]
Download directly from a provided URL instead of fetching the URL from the wordpress.org servers.
[--path=<path>]
Specify the path in which to install WordPress. Defaults to current
directory.
[--locale=<locale>]
Select which language you want to download.
[--version=<version>]
Select which version you want to download. Accepts a version number, 'latest' or 'nightly'.
[--skip-content]
Download WP without the default themes and plugins.
[--force]
Overwrites existing files, if present.
[--insecure]
Retry download without certificate validation if TLS handshake fails. Note: This makes the request vulnerable to a MITM attack.
[--extract]
Whether to extract the downloaded file. Defaults to true.
示例
$ wp core download --locale=nl_NL
Downloading WordPress 4.5.2 (nl_NL)...
md5 hash verified: c5366d05b521831dd0b29dfc386e56a5
Success: WordPress downloaded.
wp core install
运行标准WordPress安装过程。
wp core install --url=<url> --title=<site-title> --admin_user=<username> [--admin_password=<password>] --admin_email=<email> [--locale=<locale>] [--skip-email]
使用提供的URL、标题和默认管理员用户详细信息在数据库中创建WordPress表。以秒或更少的时间执行著名的5分钟安装。
注意:如果您在子目录中安装了WordPress,则需要在wp core install
之后运行wp option update siteurl
。例如,如果WordPress安装在与/wp
目录中,并且您的域名是example.com,那么您需要运行wp option update siteurl http://example.com/wp
以使您的WordPress安装正常工作。
注意:当使用自定义用户表(例如CUSTOM_USER_TABLE
)时,如果user_login已存在,则忽略管理员电子邮件和密码。如果user_login不存在,则创建新用户。
选项
--url=<url>
The address of the new site.
--title=<site-title>
The title of the new site.
--admin_user=<username>
The name of the admin user.
[--admin_password=<password>]
The password for the admin user. Defaults to randomly generated string.
--admin_email=<email>
The email address for the admin user.
[--locale=<locale>]
The locale/language for the installation (e.g. `de_DE`). Default is `en_US`.
[--skip-email]
Don't send an email notification to the new admin user.
示例
# Install WordPress in 5 seconds
$ wp core install --url=example.com --title=Example --admin_user=supervisor --admin_password=strongpassword [email protected]
Success: WordPress installed successfully.
# Install WordPress without disclosing admin_password to bash history
$ wp core install --url=example.com --title=Example --admin_user=supervisor [email protected] --prompt=admin_password < admin_password.txt
wp core is-installed
检查WordPress是否已安装。
wp core is-installed [--network]
通过检查标准数据库表是否已安装来确定WordPress是否已安装。不产生输出;使用退出代码来传达WordPress是否已安装。
选项
[--network]
Check if this is a multisite installation.
示例
# Bash script for checking if WordPress is not installed.
if ! wp core is-installed 2>/dev/null; then
# WP is not installed. Let's try installing it.
wp core install
fi
# Bash script for checking if WordPress is installed, with fallback.
if wp core is-installed 2>/dev/null; then
# WP is installed. Let's do some things we should only do in a confirmed WP environment.
wp core verify-checksums
else
# Fallback if WP is not installed.
echo 'Hey Friend, you are in the wrong spot. Move in to your WordPress directory and try again.'
fi
wp core multisite-convert
将现有的单站点安装转换为多站点安装。
wp core multisite-convert [--title=<network-title>] [--base=<url-path>] [--subdomains] [--skip-config]
创建多站点数据库表,并将多站点常量添加到wp-config.php中。
对于使用Apache的WordPress用户,请记住更新.htaccess
文件,以包含适当的多站点重写规则。
查看多站点文档以获取关于多站点如何工作的更多详细信息。
选项
[--title=<network-title>]
The title of the new network.
[--base=<url-path>]
Base path after the domain name that each site url will start with.
---
default: /
---
[--subdomains]
If passed, the network will use subdomains, instead of subdirectories. Doesn't work with 'localhost'.
[--skip-config]
Don't add multisite constants to wp-config.php.
示例
$ wp core multisite-convert
Set up multisite database tables.
Added multisite constants to wp-config.php.
Success: Network installed. Don't forget to set up rewrite rules.
wp core multisite-install
从头开始安装WordPress多站点。
wp core multisite-install [--url=<url>] [--base=<url-path>] [--subdomains] --title=<site-title> --admin_user=<username> [--admin_password=<password>] --admin_email=<email> [--skip-email] [--skip-config]
使用提供的URL、标题和默认管理员用户详细信息在数据库中创建WordPress表。然后,在数据库中创建多站点表,并将多站点常量添加到wp-config.php中。
对于使用Apache的WordPress用户,请记住更新.htaccess
文件,以包含适当的多站点重写规则。
选项
[--url=<url>]
The address of the new site.
[--base=<url-path>]
Base path after the domain name that each site url in the network will start with.
---
default: /
---
[--subdomains]
If passed, the network will use subdomains, instead of subdirectories. Doesn't work with 'localhost'.
--title=<site-title>
The title of the new site.
--admin_user=<username>
The name of the admin user.
---
default: admin
---
[--admin_password=<password>]
The password for the admin user. Defaults to randomly generated string.
--admin_email=<email>
The email address for the admin user.
[--skip-email]
Don't send an email notification to the new admin user.
[--skip-config]
Don't add multisite constants to wp-config.php.
示例
$ wp core multisite-install --title="Welcome to the WordPress" \
> --admin_user="admin" --admin_password="password" \
> --admin_email="[email protected]"
Single site database tables already present.
Set up multisite database tables.
Added multisite constants to wp-config.php.
Success: Network installed. Don't forget to set up rewrite rules.
wp core update
将WordPress更新到较新版本。
wp core update [<zip>] [--minor] [--version=<version>] [--force] [--locale=<locale>] [--insecure]
默认更新到最新版本。
如果您看到“错误:另一个更新正在运行中”,您可能需要在验证没有其他更新实际运行后运行wp option delete core_updater.lock
。
选项
[<zip>]
Path to zip file to use, instead of downloading from wordpress.org.
[--minor]
Only perform updates for minor releases (e.g. update from WP 4.3 to 4.3.3 instead of 4.4.2).
[--version=<version>]
Update to a specific version, instead of to the latest version. Alternatively accepts 'nightly'.
[--force]
Update even when installed WP version is greater than the requested version.
[--locale=<locale>]
Select which language you want to download.
[--insecure]
Retry download without certificate validation if TLS handshake fails. Note: This makes the request vulnerable to a MITM attack.
示例
# Update WordPress
$ wp core update
Updating to version 4.5.2 (en_US)...
Downloading update from https://downloads.wordpress.org/release/wordpress-4.5.2-no-content.zip...
Unpacking the update...
Cleaning up files...
No files found that need cleaning up
Success: WordPress updated successfully.
# Update WordPress using zip file.
$ wp core update ../latest.zip
Starting update...
Unpacking the update...
Success: WordPress updated successfully.
# Update WordPress to 3.1 forcefully
$ wp core update --version=3.1 --force
Updating to version 3.1 (en_US)...
Downloading update from https://wordpress.org/wordpress-3.1.zip...
Unpacking the update...
Warning: Checksums not available for WordPress 3.1/en_US. Please cleanup files manually.
Success: WordPress updated successfully.
wp core update-db
运行WordPress数据库更新过程。
wp core update-db [--network] [--dry-run]
选项
[--network]
Update databases for all sites on a network
[--dry-run]
Compare database versions without performing the update.
示例
# Update the WordPress database.
$ wp core update-db
Success: WordPress database upgraded successfully from db version 36686 to 35700.
# Update databases for all sites on a network.
$ wp core update-db --network
WordPress database upgraded successfully from db version 35700 to 29630 on example.com/
Success: WordPress database upgraded on 123/123 sites.
wp core version
显示WordPress版本。
wp core version [--extra]
选项
[--extra]
Show extended version information.
示例
# Display the WordPress version
$ wp core version
4.5.2
# Display WordPress version along with other information
$ wp core version --extra
WordPress version: 4.5.2
Database revision: 36686
TinyMCE version: 4.310 (4310-20160418)
Package language: en_US
安装中
此软件包已包含在WP-CLI本身中,无需额外安装。
要安装此软件包的最新版本,覆盖WP-CLI中包含的版本,请运行
wp package install [email protected]:wp-cli/core-command.git
贡献
我们感谢您主动为该项目做出贡献。
贡献不仅限于代码。我们鼓励您根据自己的能力以最佳方式做出贡献,例如撰写教程、在当地聚会中演示、帮助其他用户解决支持问题或修订我们的文档。
要获取更全面的介绍,请查看WP-CLI贡献指南。此软件包遵循那些政策和指南。
报告一个错误
你认为找到了一个错误?我们希望你能帮助我们将其修复。
在创建新问题之前,你应该搜索现有问题,看看是否有现有的解决方案,或者它是否已经在新版本中修复。
在你进行了一些搜索并且发现你的错误没有已打开或已修复的问题后,请创建一个新的问题。尽可能提供详细信息,如果可能,请提供清晰的复现步骤。有关更多指导,请查看我们的错误报告文档。
创建一个拉取请求
想要贡献一个新功能?请首先打开一个新问题,讨论该功能是否适合项目。
一旦你决定投入时间完成你的拉取请求,请遵循我们创建拉取请求的指南,以确保这是一个愉快的体验。有关在本地工作于此软件包的具体信息,请参阅"设置"。
支持
GitHub问题不是用于一般支持问题的地方,但你还可以尝试其他途径:https://wp-cli.org/#support
此README.md是从项目的代码库动态生成的,使用wp scaffold package-readme
(文档)。要提出更改建议,请提交针对代码库相应部分的拉取请求。