@lifterlms/utils

1.0.1-alpha.1 • Public • Published

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()][https://developer.wordpress.org/reference/functions/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 Version LifterLMS Version
1.0.0 6.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.

Package Sidebar

Install

npm i @lifterlms/utils

Weekly Downloads

0

Version

1.0.1-alpha.1

License

GPL-3.0-or-later

Unpacked Size

41.5 kB

Total Files

14

Last publish

Collaborators

  • chrisbadgett
  • brianhogg
  • jasonlifter