| Server IP : 38.190.208.107 / Your IP : 216.73.217.46 Web Server : nginx/1.28.1 System : Linux ht2026040333114 6.1.0-10-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.37-1 (2023-07-03) x86_64 User : root ( 0) PHP Version : 8.2.28 Disable Function : passthru,exec,system,putenv,chroot,chgrp,chown,shell_exec,popen,proc_open,pcntl_exec,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,imap_open,apache_setenv,eval,assert,passthru,system,exec,shell_exec,popen,proc_open MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /www/wwwroot/test20.chuangfenglink.xyz/wp-content/plugins/chatway-live-chat/app/ |
Upload File : |
<?php
/**
* Chatway reusable urls
*
* @author : Chatway
* @license : GPLv3
* */
namespace Chatway\App;
class Url {
use Singleton;
public static $environment = 'prod'; // dev | prod | local
/**
* Generates the full base URL for a given key and appends the endpoint to it.
*
* @param string $key The key representing a specific URL (e.g., 'api', 'app', or 'widget').
* @param string $endpoint The endpoint to append to the base URL.
* @return string The full URL constructed by combining the base URL and the provided endpoint.
*/
private static function base_url($key, $endpoint ) {
$urls = [];
if( self::$environment === 'dev' ) {
$urls = [
'api' => 'https://dev-api.chatway.app/api',
'app' => 'https://dev-go.chatway.app',
'widget' => 'https://dev-cdn.chatway.app'
];
} else {
$urls = [
'api' => 'https://prod-api.chatway.app/api',
'app' => 'https://go.chatway.app',
'widget' => 'https://cdn.chatway.app'
];
}
return $urls[$key] . $endpoint;
}
/**
* Constructs the iframe source URL by appending a tokenized query parameter to the base app URL.
*
* @param string $token An optional token to be appended as a query parameter in the iframe source URL.
* @return string The fully constructed iframe source URL.
*/
public static function iframe_src($token = '' ) {
return self::base_url( 'app', '/wordpress?token=' . $token );
}
/**
* Constructs the full URL for the fullscreen page based on the predefined base app URL.
*
* @return string The complete URL pointing to the fullscreen page.
*/
public static function full_screen_url() {
return self::base_url( 'app', '/fullscreen' );
}
/**
* Constructs the full API URL by appending the specified endpoint to the base API URL.
*
* @param string $endpoint The endpoint to append to the API base URL. Defaults to an empty string.
* @return string The complete API URL.
*/
public static function remote_api($endpoint = '' ) {
return self::base_url( 'api', $endpoint );
}
/**
* Generates the full URL for the widget script with the specified identifier.
*
* @param string $identifier An optional identifier used to customize the widget script URL.
* @return string The full URL for the widget script including the provided identifier parameter.
*/
public static function widget_script($identifier = '' ) {
return self::base_url( 'widget', '/widget.js?include[]=faqs&id=' . $identifier );
}
/**
* Builds and returns the complete internal API endpoint.
*
* @param string $endpoint Optional specific endpoint to append to the base API path.
* @return string The fully constructed API endpoint path.
*/
public static function internal_api($endpoint = '' ) {
return 'chatway/v1' . $endpoint;
}
/**
* Constructs and returns the complete site URL with the optional slug appended.
*
* @param string $slug Optional slug to append to the base site URL.
* @return string The fully constructed site URL.
*/
public static function site_url($slug = '' ) {
return get_site_url() . '/' . $slug;
}
/**
* Constructs and returns the complete admin URL.
*
* @param string $route Optional specific route to append to the base admin URL.
* @return string The fully constructed admin URL with the specified route.
*/
public static function admin_url($route = '' ) {
return admin_url( 'admin.php?page=chatway' ) . $route;
}
/**
* Generates and returns the URL of the landing page.
*
* @return string The URL of the landing page.
*/
public static function landing_page() {
return "https://chatway.app/";
}
/**
* Generates and returns the URL of the terms of service page.
*
* @return string The URL of the terms of service page.
*/
public static function terms_of_service() {
return "https://chatway.app/terms-of-service/";
}
/**
* Generates and returns the URL of the privacy policy page.
*
* @return string The URL of the privacy policy page.
*/
public static function privacy_policy() {
return "https://chatway.app/privacy-policy/";
}
/**
* Generates and returns the URL of the contact us page.
*
* @return string The URL of the contact us page.
*/
public static function contact_us() {
return 'https://chatway.app/contact-us/';
}
}