llms_get_endpoint_url( string $endpoint, string $value = '', string $permalink = '' )

Retrieve the full URL to a LifterLMS endpoint


Parameters Parameters

$endpoint

(string) (Required) ID of the endpoint, eg "view-courses".

$value

(string) (Optional) Endpoint query arg value (Optional as the presence of the arg is enough in most scenarios).

Default value: ''

$permalink

(string) (Optional) Base URL to append the endpoint to. Optional, uses the current page when not supplied.

Default value: ''


Top ↑

Return Return

(string)


Top ↑

Source Source

File: includes/functions/llms.functions.page.php

function llms_get_endpoint_url( $endpoint, $value = '', $permalink = '' ) {

	if ( ! $permalink ) {
		$permalink = get_permalink();
	}

	// Map endpoint to options.
	$vars     = LLMS()->query->get_query_vars();
	$endpoint = isset( $vars[ $endpoint ] ) ? $vars[ $endpoint ] : $endpoint;

	if ( get_option( 'permalink_structure' ) ) {
		if ( strstr( $permalink, '?' ) ) {
			$query_string = '?' . parse_url( $permalink, PHP_URL_QUERY );
			$permalink    = current( explode( '?', $permalink ) );

		} else {
			$query_string = '';
		}
		$url = trailingslashit( $permalink ) . $endpoint . '/' . $value . $query_string;
	} else {
		$url = add_query_arg( $endpoint, $value, $permalink );
	}

	/**
	 * Filter the final endpoint URL.
	 *
	 * @since 1.0.0
	 *
	 * @param string $url      The endpoint URL.
	 * @param string $endpoint The requested endpoint.
	 */
	return apply_filters( 'lifterlms_get_endpoint_url', $url, $endpoint );
}


Top ↑

Changelog Changelog

Changelog
Version Description
3.26.3 Unknown.
1.0.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

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