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. Pass true 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. Default WP_CLI::error(). Use WP_CLI::warning() or WP_CLI::log() where appropriate.

Default value: 'error'


Top ↑

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.


Top ↑

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;
	}

Top ↑

Changelog Changelog

Changelog
Version Description
0.0.1 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.