cognitoforms-wordpress/templates/main.php

62 lines
1.9 KiB
PHP
Raw Normal View History

2021-06-15 09:41:50 -04:00
<?php
/**
* Cognito Forms WordPress Plugin.
*
* The Cognito Forms WordPress Plugin is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License, version 2, as
* published by the Free Software Foundation.
*
* The Cognito Forms WordPress Plugin is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
require_once dirname(__FILE__) . '/../api.php';
$url = CognitoAPI::$formsBase;
if ($_GET['page'] == 'CognitoCreateForm') {
$url = $url . 'forms/new';
} elseif ($_GET['page'] == "CognitoTemplates") {
2021-06-16 23:05:44 -04:00
$url = $url . 'templates';
2021-06-15 09:41:50 -04:00
} else {
$url = $url . 'forms';
}
?>
<iframe id="cognito-frame" src="<?php print $url; ?>" style="width:100%; overflow-x: hidden;"></iframe>
<style>
2021-06-16 23:05:44 -04:00
body {
overflow: hidden;
}
#wpcontent {
padding-left: 0!important;
}
2021-06-15 09:41:50 -04:00
</style>
<script language="javascript">
2021-06-16 23:05:44 -04:00
// Remove all content injected prior to the iframe (ex. wordpress update banners)
2021-06-15 09:41:50 -04:00
var element = document.getElementById('cognito-frame');
for (; element; element = element.previousSibling) {
if (element.nodeType === 1 && element.id !== 'cognito-frame') {
element.style.display = 'none';
}
}
window.addEventListener('resize', resizeListener);
// Handler to watch for window resize to correctly update iframe height
function resizeListener(event) {
var adminheight = document.getElementById('wpadminbar').clientHeight;
document.getElementById('cognito-frame').height = (document.body.clientHeight) + "px";
}
2021-06-16 23:05:44 -04:00
resizeListener();
2021-06-15 09:41:50 -04:00
</script>