LLMS_REST_Authentication::is_rest_request()

Determine if the request is a request to a LifterLMS REST API endpoint.


Return Return

(bool)


Top ↑

Source Source

File: libraries/lifterlms-rest/includes/class-llms-rest-authentication.php

	 */
	protected function is_rest_request() {

		$request = isset( $_SERVER['REQUEST_URI'] ) ? filter_var( wp_unslash( $_SERVER['REQUEST_URI'] ), FILTER_SANITIZE_URL ) : null;
		if ( empty( $request ) ) {
			return false;
		}
		if ( empty( $request ) ) {
			return false;
		}

		$request = esc_url_raw( wp_unslash( $request ) );
		$prefix  = trailingslashit( rest_get_url_prefix() );

		$core = ( false !== strpos( $request, $prefix . 'llms/' ) );

		// Allow 3rd parties to use core auth.
		$external = ( false !== strpos( $request, $prefix . 'llms-' ) );

		return apply_filters( 'llms_is_rest_request', $core || $external, $request );



Top ↑

Changelog Changelog

Changelog
Version Description
1.0.0-beta.5 Access $_SERVER['REQUEST_URI'] via filter_var instead of llms_filter_input(), see <a href="https://bugs.php.net/bug.php?id=49184">https://bugs.php.net/bug.php?id=49184</a>.
1.0.0-beta.1 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

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