Movatterモバイル変換


[0]ホーム

URL:


WP-CLIThe command line interface for WordPress

WP-CLI

WP-CLI is the command-line interface forWordPress. You can update plugins, configure multisite installations and much more, without using a web browser.

Ongoing maintenance is made possible by:

AutomatticBluehostPantheonSiteGroundWP EngineCloudways

The current stable release isversion 2.11.0. For announcements, follow@wpcli on Twitter orsign up for email updates.Check out the roadmap for an overview of what’s planned for upcoming releases.

TestingAverage time to resolve an issuePercentage of issues still open

Quick links:Using |Installing |Support |Extending |Contributing |Credits

Using

WP-CLI provides a command-line interface for many actions you might perform in the WordPress admin. For instance,wp plugin install --activate (doc) lets you install and activate a WordPress plugin:

$wp plugininstalluser-switching--activateInstalling User Switching(1.0.9)Downloading installation package from https://downloads.wordpress.org/plugin/user-switching.1.0.9.zip...Unpacking the package...Installing the plugin...Plugin installed successfully.Activating'user-switching'...Plugin'user-switching' activated.Success: Installed 1 of 1 plugins.

WP-CLI also includes commands for many things you can’t do in the WordPress admin. For example,wp transient delete --all (doc) lets you delete one or all transients:

$wp transient delete--allSuccess: 34 transients deleted from the database.

For a more complete introduction to using WP-CLI, read theQuick Start guide. Or, catch up withshell friends to learn about helpful command line utilities.

Already feel comfortable with the basics? Jump into thecomplete list of commands for detailed information on managing themes and plugins, importing and exporting data, performing database search-replace operations and more.

Installing

Downloading the Phar file is our recommended installation method for most users. Should you need, see also our documentation onalternative installation methods (Composer,Homebrew,Docker).

Before installing WP-CLI, please make sure your environment meets the minimum requirements:

Once you’ve verified requirements, download thewp-cli.phar file usingwget orcurl:

curl-O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar

Next, check the Phar file to verify that it’s working:

php wp-cli.phar--info

To use WP-CLI from the command line by typingwp, make the file executable and move it to somewhere in your PATH. For example:

chmod +x wp-cli.pharsudo mvwp-cli.phar /usr/local/bin/wp

If WP-CLI was installed successfully, you should see something like this when you runwp --info:

$wp--infoOS:     Linux 5.10.60.1-microsoft-standard-WSL2#1 SMP Wed Aug 25 23:20:18 UTC 2021 x86_64Shell:  /usr/bin/zshPHP binary:     /usr/bin/php8.1PHP version:    8.1.0php.ini used:   /etc/php/8.1/cli/php.iniMySQL binary:   /usr/bin/mysqlMySQL version:  mysql  Ver 8.0.27-0ubuntu0.20.04.1forLinux on x86_64((Ubuntu))SQL modes:WP-CLI rootdir:        /home/wp-cli/WP-CLI vendordir:      /home/wp-cli/vendorWP_CLI phar path:WP-CLI packagesdir:    /home/wp-cli/.wp-cli/packages/WP-CLI global config:WP-CLI project config:  /home/wp-cli/wp-cli.ymlWP-CLI version: 2.11.0

Updating

You can update WP-CLI withwp cli update (doc), or by repeating the installation steps.

If WP-CLI is owned by root or another system user, you’ll need to runsudo wp cli update.

Want to live life on the edge? Runwp cli update --nightly to use the latest nightly build of WP-CLI. The nightly build is more or less stable enough for you to use in your development environment, and always includes the latest and greatest WP-CLI features.

Tab completions

WP-CLI also comes with a tab completion script for Bash and ZSH. Just downloadwp-completion.bash and source it from~/.bash_profile:

source /FULL/PATH/TO/wp-completion.bash

Don’t forget to runsource ~/.bash_profile afterwards.

If using zsh for your shell, you may need to load and startbashcompinit before sourcing. Put the following in your.zshrc:

autoload bashcompinitbashcompinitsource /FULL/PATH/TO/wp-completion.bash

Support

WP-CLI’s maintainers and contributors have limited availability to address general support questions. Thecurrent version of WP-CLI is the only officially supported version.

When looking for support, please first search for your question in these venues:

If you didn’t find an answer in one of the venues above, you can:

GitHub issues are meant for tracking enhancements to and bugs of existing commands, not general support. Before submitting a bug report, pleasereview our best practices to help ensure your issue is addressed in a timely manner.

Please do not ask support questions on Twitter. Twitter isn’t an acceptable venue for support because: 1) it’s hard to hold conversations in under 280 characters, and 2) Twitter isn’t a place where someone with your same question can search for an answer in a prior conversation.

Remember, libre != gratis; the open source license grants you the freedom to use and modify, but not commitments of other people’s time. Please be respectful, and set your expectations accordingly.

Extending

Acommand is the atomic unit of WP-CLI functionality.wp plugin install (doc) is one command.wp plugin activate (doc) is another.

WP-CLI supports registering any callable class, function, or closure as a command. It reads usage details from the callback’s PHPdoc.WP_CLI::add_command() (doc) is used for both internal and third-party command registration.

/** * Delete an option from the database. * * Returns an error if the option didn't exist. * * ## OPTIONS * * <key> * : Key for the option. * * ## EXAMPLES * *     $ wp option delete my_option *     Success: Deleted 'my_option' option. */$delete_option_cmd=function($args){list($key)=$args;if(!delete_option($key)){WP_CLI::error("Could not delete '$key' option. Does it exist?");}else{WP_CLI::success("Deleted '$key' option.");}};WP_CLI::add_command('option delete',$delete_option_cmd);

WP-CLI comes with dozens of commands. It’s easier than it looks to create a custom WP-CLI command. Read thecommands cookbook to learn more. Browse theinternal API docs to discover a variety of helpful functions you can use in your custom WP-CLI command.

Contributing

We appreciate you taking the initiative to contribute to WP-CLI. It’s because of you, and the community around you, that WP-CLI is such a great project.

Contributing isn’t limited to just code. We encourage you to contribute in the way that best fits your abilities, by writing tutorials, giving a demo at your local meetup, helping other users with their support questions, or revising our documentation.

Read through ourcontributing guidelines in the handbook for a thorough introduction to how you can get involved. Following these guidelines helps to communicate that you respect the time of other contributors on the project. In turn, they’ll do their best to reciprocate that respect when working with you, across timezones and around the world.

Leadership

WP-CLI has one project maintainer:schlessera.

On occasion, wegrant write access to contributors who have demonstrated, over a period of time, that they are capable and invested in moving the project forward.

Read thegovernance document in the handbook for more operational details about the project.

Credits

Besides the libraries defined incomposer.json, we have used code or ideas from the following projects:


[8]ページ先頭

©2009-2025 Movatter.jp