This is the same request as I made a few years ago in #1, which at the time was closed because the official wp-cli "package index" wasn't accepting new submissions. Since then, they have decided to no longer maintain this separate index, and instead simply use any composer source, such as packagist, or a git repo directly.
I've taken a few minutes to see what changes are needed, and it breaks down like this:
- Any check for
defined( 'ABSPATH' ) needs to be removed, or changed to check for defined( 'WP_CLI' ) as an alternative
add_action isn't available in the wp-cli bootstrap process, so GF_CLI_Bootstrap::load_cli() should be called unconditionally
- For the same reason,
GF_CLI_Bootstrap::load_addon() needs to be loaded differently or conditionally
- Similarly,
plugin_dir_path() isn't available during bootstrap, but is easily replaced with dirname() (and rtrim() to be really clean)
With these changes made, I can use the plugin as a global wp-cli package without any further issues. The only other small niggle is that the type in the composer.json file isn't wp-cli-package as recommended, but this isn't a strict requirement.
This is the same request as I made a few years ago in #1, which at the time was closed because the official wp-cli "package index" wasn't accepting new submissions. Since then, they have decided to no longer maintain this separate index, and instead simply use any composer source, such as packagist, or a git repo directly.
I've taken a few minutes to see what changes are needed, and it breaks down like this:
defined( 'ABSPATH' )needs to be removed, or changed to check fordefined( 'WP_CLI' )as an alternativeadd_actionisn't available in the wp-cli bootstrap process, soGF_CLI_Bootstrap::load_cli()should be called unconditionallyGF_CLI_Bootstrap::load_addon()needs to be loaded differently or conditionallyplugin_dir_path()isn't available during bootstrap, but is easily replaced withdirname()(andrtrim()to be really clean)With these changes made, I can use the plugin as a global wp-cli package without any further issues. The only other small niggle is that the
typein the composer.json file isn'twp-cli-packageas recommended, but this isn't a strict requirement.