Alert: This function’s access is marked private. This means it is not intended for use by plugin or theme developers, only in other core functions. It is listed here for completeness.
LLMS_REST_Authentication::get_rest_route( string $request )
Extract the REST route from a request URI.
Description Description
Supports pretty permalinks (/wp-json/{route}) and plain permalinks (?rest_route=/{route}).
The query string is intentionally ignored when matching the path so that an llms marker placed in a query argument cannot make a non-LifterLMS route look like a LifterLMS route.
Parameters Parameters
- $request
-
(string) (Required) The sanitized request URI.
Return Return
(string) The route relative to the REST prefix (no leading slash), or an empty string.
Source Source
File: libraries/lifterlms-rest/includes/class-llms-rest-authentication.php
private function get_rest_route( $request ) {
$prefix = rest_get_url_prefix();
$path = (string) wp_parse_url( $request, PHP_URL_PATH );
$needle = '/' . $prefix . '/';
$pos = $path ? strpos( $path, $needle ) : false;
if ( false !== $pos ) {
return ltrim( substr( $path, $pos + strlen( $needle ) ), '/' );
}
$query = (string) wp_parse_url( $request, PHP_URL_QUERY );
if ( $query ) {
parse_str( $query, $vars );
if ( ! empty( $vars['rest_route'] ) ) {
return ltrim( (string) $vars['rest_route'], '/' );
}
}
return '';
}
Expand full source code Collapse full source code View on GitHub
Changelog Changelog
| Version | Description |
|---|---|
| 1.0.8 | Introduced. |