Store Cognito base url solely in api.php
This commit is contained in:
parent
6a5c99e483
commit
78d3acb74c
2
api.php
2
api.php
|
@ -19,7 +19,7 @@
|
||||||
// Cognito API access
|
// Cognito API access
|
||||||
if ( !class_exists('CognitoAPI') ) {
|
if ( !class_exists('CognitoAPI') ) {
|
||||||
class CognitoAPI {
|
class CognitoAPI {
|
||||||
public static $formsBase = 'https://www.cognitoforms.com/';
|
public static $formsBase = 'https://cognitoforms.com/';
|
||||||
|
|
||||||
// Convert MS GUID to Short GUID
|
// Convert MS GUID to Short GUID
|
||||||
private static function guid_to_short_guid($guid) {
|
private static function guid_to_short_guid($guid) {
|
||||||
|
|
|
@ -142,6 +142,12 @@ if ( !class_exists( 'CognitoFormsPlugin' ) ) {
|
||||||
$asset_file['version']
|
$asset_file['version']
|
||||||
);
|
);
|
||||||
|
|
||||||
|
wp_add_inline_script(
|
||||||
|
'cognito-block-editor-js',
|
||||||
|
'window.COGNITO_BASEURL = "' . CognitoAPI::$formsBase . '";',
|
||||||
|
'before'
|
||||||
|
);
|
||||||
|
|
||||||
// Register block editor styles for backend.
|
// Register block editor styles for backend.
|
||||||
wp_register_style(
|
wp_register_style(
|
||||||
'cognito-block-editor-css', // Handle.
|
'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
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
$url = 'https://www.cognitoforms.com/';
|
$url = CognitoAPI::$formsBase;
|
||||||
|
|
||||||
if ($_GET['page'] == 'CognitoCreateForm') {
|
if ($_GET['page'] == 'CognitoCreateForm') {
|
||||||
$url = $url . 'forms/new';
|
$url = $url . 'forms/new';
|
||||||
|
|
Loading…
Reference in New Issue