Store Cognito base url solely in api.php
This commit is contained in:
		
							
								
								
									
										2
									
								
								api.php
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								api.php
									
									
									
									
									
								
							@@ -19,7 +19,7 @@
 | 
			
		||||
// Cognito API access
 | 
			
		||||
if ( !class_exists('CognitoAPI') ) {
 | 
			
		||||
	class CognitoAPI {
 | 
			
		||||
		public static $formsBase = 'https://www.cognitoforms.com/';
 | 
			
		||||
		public static $formsBase = 'https://cognitoforms.com/';
 | 
			
		||||
 | 
			
		||||
		// Convert MS GUID to Short GUID
 | 
			
		||||
		private static function guid_to_short_guid($guid) {
 | 
			
		||||
 
 | 
			
		||||
@@ -142,6 +142,12 @@ if ( !class_exists( 'CognitoFormsPlugin' ) ) {
 | 
			
		||||
				$asset_file['version']
 | 
			
		||||
			);
 | 
			
		||||
 | 
			
		||||
			wp_add_inline_script(
 | 
			
		||||
				'cognito-block-editor-js',
 | 
			
		||||
				'window.COGNITO_BASEURL = "' . CognitoAPI::$formsBase . '";',
 | 
			
		||||
				'before'
 | 
			
		||||
			);
 | 
			
		||||
 | 
			
		||||
			// Register block editor styles for backend.
 | 
			
		||||
			wp_register_style(
 | 
			
		||||
				'cognito-block-editor-css', // Handle.
 | 
			
		||||
 
 | 
			
		||||
@@ -1 +1,9 @@
 | 
			
		||||
export const baseUrl = 'https://forms.cognito.test';
 | 
			
		||||
declare const COGNITO_BASEURL: string;
 | 
			
		||||
 | 
			
		||||
let baseUrl: string;
 | 
			
		||||
if ( window.hasOwnProperty( 'COGNITO_BASEURL' ) )
 | 
			
		||||
	baseUrl = COGNITO_BASEURL;
 | 
			
		||||
else
 | 
			
		||||
	baseUrl = 'https://www.cognitoforms.com';
 | 
			
		||||
 | 
			
		||||
export { baseUrl };
 | 
			
		||||
 
 | 
			
		||||
@@ -16,7 +16,7 @@
 | 
			
		||||
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
$url = 'https://www.cognitoforms.com/';
 | 
			
		||||
$url = CognitoAPI::$formsBase;
 | 
			
		||||
 | 
			
		||||
if ($_GET['page'] == 'CognitoCreateForm') {
 | 
			
		||||
	$url = $url . 'forms/new';
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user