-
·
WP_CLI::add_hook()
Schedule a callback to be executed at a certain point. Usage WP_CLI::add_hook( $when, $callback ) $when (string) Identifier for the hook. $callback (callable) Callback to execute when hook is called. @return (void) Notes Hooks conceptually are very similar to WordPress actions. WP-CLI hooks are typically called before WordPress is loaded. WP-CLI hooks include: before_add_command:<command> –…
-
·
Quick Start
Congratulations! You’ve installed WP-CLI for the first time, and are ready to level-up your use of WordPress. This page contains a brief introduction to WP-CLI with some example usage. Introduction WP-CLI is a command line interface for WordPress. The project’s goal is to offer a complete alternative to the WordPress admin; for any action you…
-
·
WP_CLI::add_wp_hook()
Add a callback to a WordPress action or filter. Usage WP_CLI::add_wp_hook( $tag, $function_to_add, $priority = 10, $accepted_args = 1 ) $tag (string) Named WordPress action or filter. $function_to_add (callable) Callable to execute when the action or filter is evaluated. $priority (integer) Priority to add the callback as. $accepted_args (integer) Number of arguments to pass to…
-
·
WP_CLI::colorize()
Colorize a string for output. Usage WP_CLI::colorize( $string ) $string (string) String to colorize for output, with color tokens. @return (string) string. Notes Yes, you can change the color of command line text too. For instance, here’s how WP_CLI::success() colorizes “Success: ” WP_CLI::colorize( “%GSuccess:%n ” ) Uses \cli\Colors::colorize() to transform color tokens to display settings.…
-
·
WP_CLI::confirm()
Ask for confirmation before running a destructive operation. Usage WP_CLI::confirm( $question, $assoc_args = [] ) $question (string) Question to display before the prompt. $assoc_args (array) Skips prompt if ‘yes’ is provided. Notes If ‘y’ is provided to the question, the script execution continues. If ‘n’ or any other response is provided to the question, script…
-
·
How to start the webserver
You can use the command wp server to launches PHP’s built-in web server for a specific WordPress installation. By default, the webserver will start using the localhost and default port 8080 but, you can change them using the –host and –port options. Step 1 – Start the web server using the default settings $ wp…
-
·
Internal API
WP-CLI includes a number of utilities which are considered stable and meant to be used by commands. This also means functions and methods not listed here are considered part of the private API. They may change or disappear at any time. Internal API documentation is generated from the WP-CLI codebase on every release. To suggest…
-
·
WP-CLI Hack Day
Welcome to WP-CLI Hack Day! We appreciate you taking time to contribute to the project. We’d love to help you submit at least one pull request today. Given this goal, you’ll likely want to start with something small and attainable. After you’ve submitted your first pull request for the day, you’re welcome to work on…
-
·
Installing
Requirements WP-CLI requires PHP 7.2.24 or later. To check the version of PHP available on your system, run: php –version WP-CLI has no additional requirements beyond those of WordPress itself. Recommended installation The recommended way to install WP-CLI is by downloading the Phar build (archives similar to Java JAR files, see this article for more…
-
·
How to WP-CLI
Introduction Using WP-CLI, you can perform specific tasks using the command line instead of accessing the WordPress admin panel. In the following section, we will cover step by step some of these tasks. How-to install WordPress How to put the website in maintenance mode How-to start the webserver How to create a custom plugin Figure…