Merged
Conversation
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Update WP-CLI documentation for cli_init action
Add documentation for cli_init hook
Oct 30, 2025
Member
|
I always saw the benefit of the
but the above code: WP_CLI::add_hook( 'cli_init', 'myplugin_register_cli_commands' );still needs a check of ~ I use: add_action( 'cli_init', 'myplugin_register_cli_commands' ); |
swissspidy
reviewed
Oct 30, 2025
Member
|
Indeed, it's a WP hook, not a WP-CLI hook after all! |
swissspidy
reviewed
Oct 30, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds documentation for the new
cli_inithook introduced in wp-cli/wp-cli#4818, which provides a dedicated event for registering custom commands during WP-CLI Runner startup.Changes
guides/commands-cookbook.md: Added
cli_inithook example in the "Include in a plugin or theme" section as an alternative to theWP_CLIconstant check, with guidance on when to use each approachreferences/internal-api/wp-cli-add-hook.md: Added
cli_initto the list of available WP-CLI hooksExample
Both the traditional
WP_CLIconstant check and the newcli_inithook remain valid approaches.Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
https://api.github.com/repos/Behat/Behat/zipball/1b6b08efa995fe4135901b862d112adc7e95ecbb/usr/bin/php8.3 -n -c /tmp/oQT045 /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/Behat/Gherkin/zipball/34c9b59c59355a7b4c53b9f041c8dbd1c8acc3b4/usr/bin/php8.3 -n -c /tmp/JjOgTZ /usr/bin/composer install(http block)/usr/bin/php8.3 -n -c /tmp/oQT045 /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/PHPCSStandards/PHPCSExtra/zipball/8e89a01c7b8fed84a12a2a7f5a23a44cdbe4f62e/usr/bin/php8.3 -n -c /tmp/oQT045 /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/PHPCSStandards/PHPCSUtils/zipball/8b8e17615d04f2fc2cd46fc1d2fd888fa21b3cf9/usr/bin/php8.3 -n -c /tmp/oQT045 /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/PHPCSStandards/PHP_CodeSniffer/zipball/ad545ea9c1b7d270ce0fc9cbfb884161cd706119/usr/bin/php8.3 -n -c /tmp/JjOgTZ /usr/bin/composer install(http block)/usr/bin/php8.3 -n -c /tmp/oQT045 /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/PHPCSStandards/composer-installer/zipball/e9cf5e4bbf7eeaf9ef5db34938942602838fc2b1/usr/bin/php8.3 -n -c /tmp/JjOgTZ /usr/bin/composer install(http block)/usr/bin/php8.3 -n -c /tmp/oQT045 /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/PHPCompatibility/PHPCompatibility/zipball/71a1e55c148ec0d248f599faea63044f81a1952c/usr/bin/php8.3 -n -c /tmp/oQT045 /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/WordPress/WordPress-Coding-Standards/zipball/d2421de7cec3274ae622c22c744de9a62c7925af/usr/bin/php8.3 -n -c /tmp/oQT045 /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/Yoast/PHPUnit-Polyfills/zipball/1a6aecc9ebe4a9cea4e1047d0e6c496e52314c27/usr/bin/php8.3 -n -c /tmp/oQT045 /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/composer/pcre/zipball/b2bed4734f0cc156ee1fe9c0da2550420d99a21e/usr/bin/php8.3 -n -c /tmp/JjOgTZ /usr/bin/composer install(http block)/usr/bin/php8.3 -n -c /tmp/oQT045 /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/composer/semver/zipball/198166618906cb2de69b95d7d47e5fa8aa1b2b95/usr/bin/php8.3 -n -c /tmp/JjOgTZ /usr/bin/composer install(http block)/usr/bin/php8.3 -n -c /tmp/oQT045 /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/composer/xdebug-handler/zipball/6c1925561632e83d60a44492e0b344cf48ab85ef/usr/bin/php8.3 -n -c /tmp/JjOgTZ /usr/bin/composer install(http block)/usr/bin/php8.3 -n -c /tmp/oQT045 /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/myclabs/DeepCopy/zipball/07d290f0c47959fd5eed98c95ee5602db07e0b6a/usr/bin/php8.3 -n -c /tmp/JjOgTZ /usr/bin/composer install(http block)/usr/bin/php8.3 -n -c /tmp/oQT045 /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/nikic/PHP-Parser/zipball/3a454ca033b9e06b63282ce19562e892747449bb/usr/bin/php8.3 -n -c /tmp/oQT045 /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/php-fig/event-dispatcher/zipball/dbefd12671e8a14ec7f180cab83036ed26714bb0/usr/bin/php8.3 -n -c /tmp/oQT045 /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/php-fig/log/zipball/f16e1d5863e37f8d8c2a01719f5b34baa2b714d3/usr/bin/php8.3 -n -c /tmp/JjOgTZ /usr/bin/composer install(http block)/usr/bin/php8.3 -n -c /tmp/oQT045 /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/php-parallel-lint/PHP-Console-Highlighter/zipball/5b4803384d3303cf8e84141039ef56c8a123138d/usr/bin/php8.3 -n -c /tmp/oQT045 /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/php-parallel-lint/PHP-Parallel-Lint/zipball/6db563514f27e19595a19f45a4bf757b6401194e/usr/bin/php8.3 -n -c /tmp/oQT045 /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/sebastianbergmann/code-unit-reverse-lookup/zipball/5e3a687f7d8ae33fb362c5c0743794bbb2420a1d/usr/bin/php8.3 -n -c /tmp/oQT045 /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/sebastianbergmann/complexity/zipball/68ff824baeae169ec9f2137158ee529584553799/usr/bin/php8.3 -n -c /tmp/oQT045 /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/sebastianbergmann/environment/zipball/8074dbcd93529b357029f5cc5058fd3e43666984/usr/bin/php8.3 -n -c /tmp/oQT045 /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/sebastianbergmann/lines-of-code/zipball/856e7f6a75a84e339195d48c556f23be2ebf75d0/usr/bin/php8.3 -n -c /tmp/oQT045 /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/a95037b6d9e608ba092da1b23931e537cadc3c3c/usr/bin/php8.3 -n -c /tmp/oQT045 /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/sebastianbergmann/php-text-template/zipball/0c7b06ff49e3d5072f057eb1fa59258bf287a748/usr/bin/php8.3 -n -c /tmp/oQT045 /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/sebastianbergmann/phpunit/zipball/e24fb46da450d8e6a5788670513c1af1424f16ca/usr/bin/php8.3 -n -c /tmp/oQT045 /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/symfony/dependency-injection/zipball/82119812ab0bf3425c1234d413efd1b19bb92ae4/usr/bin/php8.3 -n -c /tmp/oQT045 /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/symfony/event-dispatcher-contracts/zipball/59eb412e93815df44f05f342958efa9f46b1e586/usr/bin/php8.3 -n -c /tmp/oQT045 /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/symfony/event-dispatcher/zipball/b7dc69e71de420ac04bc9ab830cf3ffebba48191/usr/bin/php8.3 -n -c /tmp/oQT045 /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/symfony/finder/zipball/9f696d2f1e340484b4683f7853b273abff94421f/usr/bin/php8.3 -n -c /tmp/oQT045 /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/symfony/polyfill-ctype/zipball/a3cc8b044a6ea513310cbd48ef7333b384945638/usr/bin/php8.3 -n -c /tmp/oQT045 /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/symfony/translation-contracts/zipball/df210c7a2573f1913b2d17cc95f90f53a73d8f7d/usr/bin/php8.3 -n -c /tmp/oQT045 /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/symfony/translation/zipball/ec25870502d0c7072d086e8ffba1420c85965174/usr/bin/php8.3 -n -c /tmp/oQT045 /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/symfony/yaml/zipball/90208e2fc6f68f613eae7ca25a2458a931b1bacc/usr/bin/php8.3 -n -c /tmp/oQT045 /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/wp-cli/mustache.php/zipball/ca23b97ac35fbe01c160549eb634396183d04a59/usr/bin/php8.3 -n -c /tmp/oQT045 /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/wp-cli/php-cli-tools/zipball/f12b650d3738e471baed6dd47982d53c5c0ab1c3/usr/bin/php8.3 -n -c /tmp/oQT045 /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/wp-cli/spyc/zipball/6aa0b4da69ce9e9a2c8402dab8d43cf32c581cc7/usr/bin/php8.3 -n -c /tmp/oQT045 /usr/bin/composer install --no-interaction(http block)https://api.github.com/repos/wp-cli/wp-cli-tests/zipball/f81af5773bd40962fb973e238acd26b39b1b7341/usr/bin/php8.3 -n -c /tmp/oQT045 /usr/bin/composer install --no-interaction(http block)If you need me to access, download, or install something from one of these locations, you can either:
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.