PluginProbe
Image Optimizer – Compress Images and Convert to WebP or AVIF / 1.4.1
Image Optimizer – Compress Images and Convert to WebP or AVIF v1.4.1
1.7.7 1.7.6 1.7.5 1.7.4 trunk 1.0.0 1.0.1 1.0.2 1.1.0 1.2.0 1.2.1 1.3.0 1.4.0 1.4.1 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.6.0 1.6.1 1.6.2 1.6.3 1.6.4 1.6.5 All 33 releases
image-optimization / modules / connect / classes / utils.php

utils.php in Image Optimizer – Compress Images and Convert to WebP or AVIF 1.4.1, at modules/connect/classes/utils.php

79 lines 1.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace ImageOptimization\Modules\Connect\Classes;
4
5 if ( ! defined( 'ABSPATH' ) ) {
6 exit; // Exit if accessed directly
7 }
8
9 /**
10 * Class Utils
11 */
12 class Utils {
13 /**
14 * get_clients_url
15 * @return string
16 */
17 public static function get_clients_url(): string {
18 return Config::BASE_URL . '/api/v1/clients';
19 }
20
21 /**
22 * get_redirect_uri
23 * @return string
24 */
25 public static function get_redirect_uri(): string {
26 if ( false !== strpos( Config::ADMIN_PAGE, '?page=' ) ) {
27 return admin_url( Config::ADMIN_PAGE );
28 }
29 return admin_url( 'options-general.php?page=' . Config::ADMIN_PAGE );
30 }
31
32 public static function get_auth_url(): string {
33 return Config::BASE_URL . '/v1/oauth2/auth';
34 }
35
36 /**
37 * Get full authorization URL with all required parameters
38 *
39 * @param string $client_id
40 *
41 * @return string
42 */
43 public static function get_authorize_url( string $client_id ): string {
44 return add_query_arg( [
45 'client_id' => $client_id,
46 'redirect_uri' => rawurlencode( self::get_redirect_uri() ),
47 'response_type' => 'code',
48 'scope' => Config::SCOPES,
49 'state' => wp_create_nonce( Config::STATE_NONCE ),
50 ], self::get_auth_url() );
51 }
52
53 /**
54 * get_deactivation_url
55 * @param string $client_id
56 *
57 * @return string
58 */
59 public static function get_deactivation_url( string $client_id ): string {
60 return Config::BASE_URL . "/api/v1/clients/{$client_id}/activation";
61 }
62
63 public static function get_jwks_url(): string {
64 return Config::BASE_URL . '/v1/.well-known/jwks.json';
65 }
66
67 /**
68 * get_sessions_url
69 * @return string
70 */
71 public static function get_sessions_url(): string {
72 return Config::BASE_URL . '/api/v1/session';
73 }
74
75 public static function get_token_url(): string {
76 return Config::BASE_URL . '/api/v1/oauth2/token';
77 }
78 }
79