AbstractCommand::get_addon( string $slug, bool|LifterLMSCLICommandsWP_Error|string $err = false, string $err_type = 'error' )
Retrieve an LLMS_Add_On object for a given add-on by it’s slug.
Parameters Parameters
- $slug
-
(string) (Required) An add-on slug. Must be prefixed.
- $err
-
(bool|LifterLMSCLICommandsWP_Error|string) (Optional) If truthy, will return
null
and use log to the console using a WP_CLI method as defined by $err_type. Passtrue
to output a default error message. Pass a WP_Error object or string to use as the error.Default value: false
- $err_type
-
(string) (Optional) Method to pass
$err
to when an error is encountered. DefaultWP_CLI::error()
. UseWP_CLI::warning()
orWP_CLI::log()
where appropriate.Default value: 'error'
Return Return
(LifterLMSCLICommandsLLMS_Add_On|boolean|null) Returns an add-on object if the add-on can be located or false
if not found. Returns null
when an error is encountered and $err
is a truthy.
Source Source
File: libraries/lifterlms-cli/src/Commands/AbstractCommand.php
protected function get_addon( $slug, $err = false, $err_type = 'error' ) { $addon = llms_get_add_on( $this->prefix_slug( $slug ), 'slug' ); $exists = ! empty( $addon->get( 'id' ) ); if ( ! $exists && $err ) { $err = is_bool( $err ) ? sprintf( 'Invalid slug: %s.', $slug ) : $err; return \WP_CLI::$err_type( $err ); } return ! $exists ? false : $addon; }
Expand full source code Collapse full source code View on GitHub
Changelog Changelog
Version | Description |
---|---|
0.0.1 | Introduced. |