1.0.1-alpha.1 • Published 2 years ago

@lifterlms/utils v1.0.1-alpha.1

Weekly downloads
-
License
GPL-3.0-or-later
Repository
github
Last release
2 years ago

LifterLMS JS Utilities

Javascript utility library for use in LifterLMS and LifterLMS add-ons.

Usage in a LifterLMS add-on

This package is included in the LifterLMS core plugin as a module and registered using the WordPress scripts dependency API (see wp_register_script()).

To use components you can add llms-utils as a dependency to your script and access the module via window.llms.components, for example:

const { getAdminUrl } = window.llms.utils;

Installation

Install the module as a dependency in your project:

npm i -S @lifterlms/utils`

LifterLMS Versions

The following table records the module version and which LifterLMS versions it has been included in.

Module VersionLifterLMS Version
1.0.06.0.0

Changelog

View the Changelog

API Docs

getAdminUrl

Retrieves the WordPress admin URL.

This function relies on the presence of localized data from the LifterLMS plugin which is only present on the WordPress admin panel. If used out of context a default partial path url, /wp-admin will be returned.

Returns

  • string: The WP Admin URL.

trailingSlashIt

Adds a trailing forward slash to a given string.

Parameters

  • str string: A string with or without a trailing forward slash.

Returns

  • string: The original string with a trailing forward slash added.

untrailingSlashIt

Remove trailing forward slash from a given string.

Parameters

  • str string: A string with or without a trailing forward slash.

Returns

  • string: The original string with the trailing forward slash removed.