# betterlinks/trunk/includes/API.php

BetterLinks – Link Shortener, Link Cloaking, Redirects, Affiliate Link Manager &amp; MCP, version trunk. 34 lines.

- Page: https://pluginprobe.com/plugins/betterlinks/trunk/code/includes/API.php
- Raw: https://pluginprobe.com/plugins/betterlinks/trunk/raw/includes/API.php
- Modified: 2026-08-21T07:10:22+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/betterlinks/trunk/code/includes/API.php#L10-L20`.

```php
<?php
namespace BetterLinks;
if ( ! defined( 'ABSPATH' ) ) { exit; }

class API {

	public static function init() {
		new API\Settings();
		new API\Links();
		new API\Terms();
		new API\Clicks();
		new API\Geolocation();
		new API\QuickLink();
		new API\AIBulkLinks();
	}
	public static function dispatch_hook() {
		$self = new self();
		add_filter( 'jwt_auth_whitelist', array( $self, 'whitelist_API' ) );
		add_filter( 'rest_url', array( $self, 'rest_url_ssl' ) );
	}
	public function whitelist_API( $endpoints ) {
		$endpoints[] = '/wp-json/' . BETTERLINKS_PLUGIN_SLUG . '/v1/*';
		$endpoints[] = '/index.php?rest_route=/' . BETTERLINKS_PLUGIN_SLUG . '/v1/*';
		return $endpoints;
	}
	public function rest_url_ssl( $url ) {
		if ( is_ssl() || ( is_admin() && force_ssl_admin() ) ) {
			$url = set_url_scheme( $url, 'https' );
			return $url;
		}
		return $url;
	}
}

```
