LLMS_View_Manager::get_url( string $role, string|false $href = false, array $args = array() )

Get a view url for the requested view.


Parameters Parameters

$role

(string) (Required) Role to view the screen as. Accepts "self", "visitor", or "student".

$href

(string|false) (Optional) The URL to create a URL for. If false, uses $_SERVER['REQUEST_URI'].

Default value: false

$args

(array) (Optional) Additional query args to add to the url.

Default value: array()


Top ↑

Return Return

(string)


Top ↑

Source Source

File: includes/class.llms.view.manager.php

	public static function get_url( $role, $href = false, $args = array() ) {

		// If we want to view as "self" we should remove the query vars (if they're set).
		if ( 'self' === $role ) {
			return remove_query_arg( array( 'llms-view-as', 'view_nonce' ), $href );
		}

		// Create a new URL.
		$args['llms-view-as'] = $role;
		$href                 = add_query_arg( $args, $href );
		return html_entity_decode( esc_url( wp_nonce_url( $href, 'llms-view-as', 'view_nonce' ) ) );

	}


Top ↑

Changelog Changelog

Changelog
Version Description
4.2.0 Take into account already present query args. e.g. ?plan=X.
4.16.0 Changed method signature to add the $href parameter and changed access from private to public static.
3.7.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

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