diff --git a/api.php b/api.php index f347647..7e9b957 100644 --- a/api.php +++ b/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) { diff --git a/cognito-forms.php b/cognito-forms.php index 47d141b..d1dceea 100644 --- a/cognito-forms.php +++ b/cognito-forms.php @@ -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. diff --git a/src/globals.ts b/src/globals.ts index 8867fc3..65d2b43 100644 --- a/src/globals.ts +++ b/src/globals.ts @@ -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 }; diff --git a/templates/main.php b/templates/main.php index 5998770..05b9907 100755 --- a/templates/main.php +++ b/templates/main.php @@ -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';