Skip to content

Ability to use as standalone WP-CLI Package #39

@dotsam

Description

@dotsam

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:

  1. Any check for defined( 'ABSPATH' ) needs to be removed, or changed to check for defined( 'WP_CLI' ) as an alternative
  2. add_action isn't available in the wp-cli bootstrap process, so GF_CLI_Bootstrap::load_cli() should be called unconditionally
  3. For the same reason, GF_CLI_Bootstrap::load_addon() needs to be loaded differently or conditionally
  4. 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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions