| 1 |
<?php |
| 2 |
namespace BetterLinks; |
| 3 |
if ( ! defined( 'ABSPATH' ) ) { exit; } |
| 4 |
|
| 5 |
class API { |
| 6 |
|
| 7 |
public static function init() { |
| 8 |
new API\Settings(); |
| 9 |
new API\Links(); |
| 10 |
new API\Terms(); |
| 11 |
new API\Clicks(); |
| 12 |
new API\Geolocation(); |
| 13 |
new API\QuickLink(); |
| 14 |
new API\AIBulkLinks(); |
| 15 |
} |
| 16 |
public static function dispatch_hook() { |
| 17 |
$self = new self(); |
| 18 |
add_filter( 'jwt_auth_whitelist', array( $self, 'whitelist_API' ) ); |
| 19 |
add_filter( 'rest_url', array( $self, 'rest_url_ssl' ) ); |
| 20 |
} |
| 21 |
public function whitelist_API( $endpoints ) { |
| 22 |
$endpoints[] = '/wp-json/' . BETTERLINKS_PLUGIN_SLUG . '/v1/*'; |
| 23 |
$endpoints[] = '/index.php?rest_route=/' . BETTERLINKS_PLUGIN_SLUG . '/v1/*'; |
| 24 |
return $endpoints; |
| 25 |
} |
| 26 |
public function rest_url_ssl( $url ) { |
| 27 |
if ( is_ssl() || ( is_admin() && force_ssl_admin() ) ) { |
| 28 |
$url = set_url_scheme( $url, 'https' ); |
| 29 |
return $url; |
| 30 |
} |
| 31 |
return $url; |
| 32 |
} |
| 33 |
} |
| 34 |
|