Clean up legacy code
This commit is contained in:
parent
c26ac6874d
commit
b2b3fca468
64
api.php
64
api.php
|
@ -1,64 +0,0 @@
|
|||
<?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
|
||||
*/
|
||||
|
||||
// Cognito API access
|
||||
class CognitoAPI {
|
||||
public static $servicesBase = 'https://services.cognitoforms.com/';
|
||||
public static $formsBase = 'https://www.cognitoforms.com/';
|
||||
|
||||
// Fetches all forms for an organization
|
||||
// $api_key - API Key for the organization
|
||||
public static function get_forms($api_key) {
|
||||
$response = wp_remote_fopen(self::$servicesBase . 'forms/api/' . $api_key . '/forms');
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
// Fetches organization information for a given member
|
||||
// $session_token - Valid session token
|
||||
public static function get_organization($session_token) {
|
||||
$response = wp_remote_fopen(self::$servicesBase . 'member/admin/organization?token=' . urlencode($session_token));
|
||||
$organization = json_decode($response);
|
||||
|
||||
return $organization;
|
||||
}
|
||||
|
||||
// Builds form embed script
|
||||
public static function get_form_embed_script($public_key, $formId) {
|
||||
$base = self::$servicesBase;
|
||||
return <<< EOF
|
||||
<div class="cognito">
|
||||
<script src="{$base}session/script/{$public_key}"></script>
|
||||
<script>Cognito.load("forms", { id: "{$formId}" });</script>
|
||||
</div>
|
||||
EOF;
|
||||
}
|
||||
|
||||
// Builds Cognito module embed script
|
||||
public static function get_embed_script($key, $module) {
|
||||
$base = self::$servicesBase;
|
||||
return <<< EOF
|
||||
<div class="cognito">
|
||||
<script src="{$base}session/script/{$key}"></script>
|
||||
<script>Cognito.load("{$module}");</script>
|
||||
</div>
|
||||
EOF;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
BIN
cogicon.ico
BIN
cogicon.ico
Binary file not shown.
Before Width: | Height: | Size: 1.1 KiB |
29
plugin.php
29
plugin.php
|
@ -69,19 +69,6 @@ if ( !class_exists('CognitoFormsPlugin') ) {
|
|||
public function admin_init() {
|
||||
if(!current_user_can('edit_posts') && !current_user_can('edit_pages')) return;
|
||||
|
||||
register_setting('cognito_plugin', 'cognito_api_key');
|
||||
register_setting('cognito_plugin', 'cognito_admin_key');
|
||||
register_setting('cognito_plugin', 'cognito_public_key');
|
||||
register_setting('cognito_plugin', 'cognito_organization');
|
||||
|
||||
// If the flag to delete options was passed-in, delete them
|
||||
if (isset($_GET['cog_clear']) && $_GET['cog_clear'] == '1') {
|
||||
delete_option('cognito_api_key');
|
||||
delete_option('cognito_admin_key');
|
||||
delete_option('cognito_public_key');
|
||||
delete_option('cognito_organization');
|
||||
}
|
||||
|
||||
// Initialize TinyMCE Plugin
|
||||
$this->tinymce_init();
|
||||
}
|
||||
|
@ -138,7 +125,7 @@ if ( !class_exists('CognitoFormsPlugin') ) {
|
|||
}
|
||||
|
||||
// Set up TinyMCE buttons
|
||||
public function mce_buttons($buttons) {
|
||||
public function mce_buttons( $buttons ) {
|
||||
array_push($buttons, '|', 'cognito');
|
||||
return $buttons;
|
||||
}
|
||||
|
@ -151,22 +138,16 @@ if ( !class_exists('CognitoFormsPlugin') ) {
|
|||
|
||||
// Initialize administration menu (left-bar)
|
||||
public function admin_menu() {
|
||||
add_menu_page('Cognito Forms', 'Cognito Forms', 'manage_options', 'Cognito', array($this, 'main_page'), "data:image/svg+xml;base64," . base64_encode( '<?xml version="1.0" encoding="UTF-8"?><svg id="icon" version="1.1" viewBox="0 0 18 18" xmlns="http://www.w3.org/2000/svg"><path fill="black" d="m8.0125 1.0813-0.41402 2.2771a5.9329 5.9329 0 0 0-1.5823 0.6472l-1.8893-1.292-1.3777 1.3158 1.2183 1.9987a5.5187 5.5187 0 0 0-0.65672 1.5942l-2.2295 0.40212v1.9987l2.2652 0.41402a6.0913 6.0913 0 0 0 0.671 1.5847l-1.2682 1.8512 1.3777 1.4491 1.875-1.2896a5.9573 5.9573 0 0 0 1.5966 0.68052l0.40212 2.2057h1.9868l0.40212-2.2652a6.5543 6.5543 0 0 0 1.6323-0.6591l1.8512 1.2801 1.4134-1.4015-1.292-1.8631a6.6517 6.6517 0 0 0 0.69479-1.6323l2.2295-0.40212v-1.9868l-2.2295-0.39023a6.3472 6.3472 0 0 0-0.68289-1.6204l1.2801-1.8512-1.4134-1.4253-1.8512 1.3158a10.087 10.087 0 0 0-1.6085-0.6591l-0.41402-2.2771zm1.0731 3.6667a3.8984 3.8984 0 0 1 2.96 1.2183 3.8375 3.8375 0 0 1 0.81614 1.2183 3.0944 3.0944 0 0 1 0.2308 0.71859l-2.4365 0.44019a1.6203 1.6203 0 0 0-1.6561-1.1826 1.6325 1.6325 0 0 0-1.2183 0.52347 1.9492 1.9492 0 0 0-0.52347 1.3158 1.8639 1.8639 0 0 0 0.52347 1.3396 1.6203 1.6203 0 0 0 1.2183 0.51158 1.669 1.669 0 0 0 1.2183-0.44971 1.8396 1.8396 0 0 0 0.40212-0.6829l1.875 0.35453 0.60913 0.13325-0.18084 0.49968a4.6781 4.6781 0 0 1-1.0113 1.4729 3.935 3.935 0 0 1-2.9124 1.0612 4.1421 4.1421 0 0 1-4.1902-4.045v-0.19511a4.069 4.069 0 0 1 1.2183-3.0338 4.1177 4.1177 0 0 1 3.0576-1.2183z" stroke-width="1.2183"/></svg>' ) );
|
||||
add_submenu_page('Cognito', 'Cognito Forms', 'View Forms', 'manage_options', 'Cognito', array($this, 'main_page'));
|
||||
add_submenu_page('Cognito', 'Create Form', 'New Form', 'manage_options', 'CognitoCreateForm', array($this, 'main_page'));
|
||||
add_submenu_page('Cognito', 'Templates', 'Templates', 'manage_options', 'CognitoTemplates', array($this, 'main_page'));
|
||||
|
||||
add_options_page('Cognito Options', 'Cognito Forms', 'manage_options', 'CognitoOptions', array($this, 'options_page'));
|
||||
add_menu_page( 'Cognito Forms', 'Cognito Forms', 'manage_options', 'Cognito', array( $this, 'main_page' ), "data:image/svg+xml;base64," . base64_encode( '<?xml version="1.0" encoding="UTF-8"?><svg id="icon" version="1.1" viewBox="0 0 18 18" xmlns="http://www.w3.org/2000/svg"><path fill="black" d="m8.0125 1.0813-0.41402 2.2771a5.9329 5.9329 0 0 0-1.5823 0.6472l-1.8893-1.292-1.3777 1.3158 1.2183 1.9987a5.5187 5.5187 0 0 0-0.65672 1.5942l-2.2295 0.40212v1.9987l2.2652 0.41402a6.0913 6.0913 0 0 0 0.671 1.5847l-1.2682 1.8512 1.3777 1.4491 1.875-1.2896a5.9573 5.9573 0 0 0 1.5966 0.68052l0.40212 2.2057h1.9868l0.40212-2.2652a6.5543 6.5543 0 0 0 1.6323-0.6591l1.8512 1.2801 1.4134-1.4015-1.292-1.8631a6.6517 6.6517 0 0 0 0.69479-1.6323l2.2295-0.40212v-1.9868l-2.2295-0.39023a6.3472 6.3472 0 0 0-0.68289-1.6204l1.2801-1.8512-1.4134-1.4253-1.8512 1.3158a10.087 10.087 0 0 0-1.6085-0.6591l-0.41402-2.2771zm1.0731 3.6667a3.8984 3.8984 0 0 1 2.96 1.2183 3.8375 3.8375 0 0 1 0.81614 1.2183 3.0944 3.0944 0 0 1 0.2308 0.71859l-2.4365 0.44019a1.6203 1.6203 0 0 0-1.6561-1.1826 1.6325 1.6325 0 0 0-1.2183 0.52347 1.9492 1.9492 0 0 0-0.52347 1.3158 1.8639 1.8639 0 0 0 0.52347 1.3396 1.6203 1.6203 0 0 0 1.2183 0.51158 1.669 1.669 0 0 0 1.2183-0.44971 1.8396 1.8396 0 0 0 0.40212-0.6829l1.875 0.35453 0.60913 0.13325-0.18084 0.49968a4.6781 4.6781 0 0 1-1.0113 1.4729 3.935 3.935 0 0 1-2.9124 1.0612 4.1421 4.1421 0 0 1-4.1902-4.045v-0.19511a4.069 4.069 0 0 1 1.2183-3.0338 4.1177 4.1177 0 0 1 3.0576-1.2183z" stroke-width="1.2183"/></svg>' ) );
|
||||
add_submenu_page( 'Cognito', 'Cognito Forms', 'View Forms', 'manage_options', 'Cognito', array( $this, 'main_page' ) );
|
||||
add_submenu_page( 'Cognito', 'Create Form', 'New Form', 'manage_options', 'CognitoCreateForm', array( $this, 'main_page' ) );
|
||||
add_submenu_page( 'Cognito', 'Templates', 'Templates', 'manage_options', 'CognitoTemplates', array( $this, 'main_page' ) );
|
||||
}
|
||||
|
||||
// Entrypoint for Cognito Forms access
|
||||
public function main_page() {
|
||||
include 'templates/main.php';
|
||||
}
|
||||
|
||||
public function options_page() {
|
||||
include 'templates/options.php';
|
||||
}
|
||||
}
|
||||
|
||||
new CognitoFormsPlugin;
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
<svg version="1.1" viewBox="-4.6 230 110.9 111" xmlns="http://www.w3.org/2000/svg"><path id="path4" class="st0" d="M 48.599609 0 L 45.699219 16 C 41.699219 17.1 37.999609 18.4 34.599609 20.5 L 21.5 11.5 L 11.699219 20.699219 L 20.599609 34.699219 C 18.399609 38.199219 16.9 41.900391 16 45.900391 L 0 48.699219 L 0 62.699219 L 15.900391 65.599609 C 17.000391 69.699609 18.499219 73.4 20.699219 77 C 20.699219 77 21.199609 77.9 20.599609 77 L 20.5 76.900391 L 11.5 90 L 21.300781 99.800781 L 34.5 90.800781 C 38 93.000781 41.699219 94.499609 45.699219 95.599609 L 48.5 111 L 62.400391 111 L 65.199219 95.099609 C 69.199219 94.099609 73.099609 92.5 76.599609 90.5 L 89.699219 99.5 L 99.5 89.699219 L 90.5 76.599609 C 92.6 73.099609 94.200781 69.299219 95.300781 65.199219 L 110.90039 62.400391 L 110.90039 48.5 L 95.300781 45.699219 C 94.200781 41.699219 92.7 37.900781 90.5 34.300781 L 99.5 21.199219 L 89.699219 11.400391 L 76.599609 20.599609 C 72.699609 18.299609 65.400391 16 65.400391 16 L 62.5 0 L 48.599609 0 z M 55.800781 26.599609 C 63.900781 26.599609 70.7 29.300391 76 34.900391 C 78.2 37.200391 80.1 39.799609 81.5 43.099609 C 80.6 44.899609 79.9 46.699219 79.5 48.699219 L 66.599609 50.900391 C 64.599609 45.300391 60.699219 42.900391 55.199219 42.900391 C 51.599219 42.900391 48.7 44.1 46.5 46.5 C 44.2 48.9 43.099609 51.899219 43.099609 55.699219 C 43.099609 59.299219 44.200391 62.199609 46.400391 64.599609 C 48.700391 66.999609 51.500391 68.099609 54.900391 68.099609 C 58.400391 68.099609 61.099219 67.1 63.199219 65 C 64.499219 63.8 65.3 62.300391 66 60.400391 L 79.400391 62.900391 L 79.400391 62.800781 C 79.800391 64.500781 80.399609 66.199219 81.099609 67.699219 C 79.699609 71.099219 77.700781 74.2 74.800781 77 C 69.800781 81.8 63.300781 84.199219 55.300781 84.199219 C 47.200781 84.199219 40.300781 81.5 34.800781 76 C 29.300781 70.5 26.5 63.699609 26.5 55.599609 C 26.5 47.399609 29.3 40.500391 35 34.900391 C 40.6 29.400391 47.600781 26.599609 55.800781 26.599609 z " transform="translate(-4.6,230)" /></svg>
|
After Width: | Height: | Size: 2.0 KiB |
|
@ -1,3 +0,0 @@
|
|||
import * as React from 'react';
|
||||
|
||||
export default <svg version="1.1" viewBox="-4.6 230 110.9 111" xmlns="http://www.w3.org/2000/svg"><path id="path4" className="st0" d="M 48.599609 0 L 45.699219 16 C 41.699219 17.1 37.999609 18.4 34.599609 20.5 L 21.5 11.5 L 11.699219 20.699219 L 20.599609 34.699219 C 18.399609 38.199219 16.9 41.900391 16 45.900391 L 0 48.699219 L 0 62.699219 L 15.900391 65.599609 C 17.000391 69.699609 18.499219 73.4 20.699219 77 C 20.699219 77 21.199609 77.9 20.599609 77 L 20.5 76.900391 L 11.5 90 L 21.300781 99.800781 L 34.5 90.800781 C 38 93.000781 41.699219 94.499609 45.699219 95.599609 L 48.5 111 L 62.400391 111 L 65.199219 95.099609 C 69.199219 94.099609 73.099609 92.5 76.599609 90.5 L 89.699219 99.5 L 99.5 89.699219 L 90.5 76.599609 C 92.6 73.099609 94.200781 69.299219 95.300781 65.199219 L 110.90039 62.400391 L 110.90039 48.5 L 95.300781 45.699219 C 94.200781 41.699219 92.7 37.900781 90.5 34.300781 L 99.5 21.199219 L 89.699219 11.400391 L 76.599609 20.599609 C 72.699609 18.299609 65.400391 16 65.400391 16 L 62.5 0 L 48.599609 0 z M 55.800781 26.599609 C 63.900781 26.599609 70.7 29.300391 76 34.900391 C 78.2 37.200391 80.1 39.799609 81.5 43.099609 C 80.6 44.899609 79.9 46.699219 79.5 48.699219 L 66.599609 50.900391 C 64.599609 45.300391 60.699219 42.900391 55.199219 42.900391 C 51.599219 42.900391 48.7 44.1 46.5 46.5 C 44.2 48.9 43.099609 51.899219 43.099609 55.699219 C 43.099609 59.299219 44.200391 62.199609 46.400391 64.599609 C 48.700391 66.999609 51.500391 68.099609 54.900391 68.099609 C 58.400391 68.099609 61.099219 67.1 63.199219 65 C 64.499219 63.8 65.3 62.300391 66 60.400391 L 79.400391 62.900391 L 79.400391 62.800781 C 79.800391 64.500781 80.399609 66.199219 81.099609 67.699219 C 79.699609 71.099219 77.700781 74.2 74.800781 77 C 69.800781 81.8 63.300781 84.199219 55.300781 84.199219 C 47.200781 84.199219 40.300781 81.5 34.800781 76 C 29.300781 70.5 26.5 63.699609 26.5 55.599609 C 26.5 47.399609 29.3 40.500391 35 34.900391 C 40.6 29.400391 47.600781 26.599609 55.800781 26.599609 z " transform="translate(-4.6,230)" /></svg>;
|
|
@ -1,55 +0,0 @@
|
|||
/**
|
||||
* WordPress dependencies
|
||||
*/
|
||||
import * as React from 'react';
|
||||
import { __ } from '@wordpress/i18n';
|
||||
import {
|
||||
ToolbarButton,
|
||||
PanelBody,
|
||||
ToggleControl,
|
||||
ToolbarGroup,
|
||||
} from '@wordpress/components';
|
||||
import { BlockControls, InspectorControls } from '@wordpress/block-editor';
|
||||
import { edit } from '@wordpress/icons';
|
||||
|
||||
const EmbedControls = ( {
|
||||
blockSupportsResponsive,
|
||||
showEditButton,
|
||||
themeSupportsResponsive,
|
||||
allowResponsive,
|
||||
getResponsiveHelp,
|
||||
toggleResponsive,
|
||||
switchBackToURLInput,
|
||||
} ) => (
|
||||
<>
|
||||
<BlockControls>
|
||||
<ToolbarGroup>
|
||||
{ showEditButton && (
|
||||
<ToolbarButton
|
||||
className="components-toolbar__control"
|
||||
label={ __( 'Edit URL' ) }
|
||||
icon={ edit }
|
||||
onClick={ switchBackToURLInput }
|
||||
/>
|
||||
) }
|
||||
</ToolbarGroup>
|
||||
</BlockControls>
|
||||
{ themeSupportsResponsive && blockSupportsResponsive && (
|
||||
<InspectorControls>
|
||||
<PanelBody
|
||||
title={ __( 'Media settings' ) }
|
||||
className="blocks-responsive"
|
||||
>
|
||||
<ToggleControl
|
||||
label={ __( 'Resize for smaller devices' ) }
|
||||
checked={ allowResponsive }
|
||||
help={ getResponsiveHelp }
|
||||
onChange={ toggleResponsive }
|
||||
/>
|
||||
</PanelBody>
|
||||
</InspectorControls>
|
||||
) }
|
||||
</>
|
||||
);
|
||||
|
||||
export default EmbedControls;
|
|
@ -10,7 +10,7 @@ import {
|
|||
InspectorControls,
|
||||
} from '@wordpress/block-editor';
|
||||
|
||||
import CogIcon from '@/assets/cogicon';
|
||||
import { ReactComponent as CogIcon } from '@/assets/cogicon.svg';
|
||||
import SelectDialog from '@/components/select-dialog';
|
||||
import PreviewForm from '@/components/preview-form';
|
||||
import { BlockAttributes, EmbedMode } from '@/types';
|
||||
|
|
|
@ -12,7 +12,7 @@ import { BlockAttributes } from './types';
|
|||
import Edit from './edit';
|
||||
import Save from './save';
|
||||
|
||||
import CogIcon from './assets/cogicon';
|
||||
import { ReactComponent as CogIcon } from './assets/cogicon.svg';
|
||||
|
||||
registerBlockType<BlockAttributes>( 'cognito-forms/cognito-embed', {
|
||||
title: 'Cognito Forms',
|
||||
|
|
|
@ -1,29 +0,0 @@
|
|||
<h2>Cognito Forms</h2>
|
||||
|
||||
<form method="post" action="options.php">
|
||||
<?php settings_fields('cognito_plugin'); ?>
|
||||
|
||||
<table class="form-table">
|
||||
<tr valign="top">
|
||||
<th scope="row">API Key</th>
|
||||
<td><input type="text" name="cognito_api_key" style="width:300px;" value="<?php echo get_option('cognito_api_key'); ?>" /></td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<th scope="row">Admin API Key</th>
|
||||
<td><input type="text" name="cognito_admin_key" style="width:300px;" value="<?php echo get_option('cognito_admin_key'); ?>" /></td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<th scope="row">Public API Key</th>
|
||||
<td><input type="text" name="cognito_public_key" style="width:300px;" value="<?php echo get_option('cognito_public_key'); ?>" /></td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<th scope="row">Organization Code</th>
|
||||
<td><input type="text" name="cognito_organization" style="width:300px;" value="<?php echo get_option('cognito_organization'); ?>" /></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<p class="submit">
|
||||
<input type="submit" class="button-primary" value="<?php _e('Save Changes') ?>" />
|
||||
</p>
|
||||
|
||||
</form>
|
|
@ -1,20 +0,0 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Form Selection</title>
|
||||
</head>
|
||||
<body>
|
||||
<textarea id="embed-code"></textarea>
|
||||
<button type="submit" onclick="postEmbedCode()">Submit</button>
|
||||
|
||||
<script type="text/javascript">
|
||||
function postEmbedCode(event) {
|
||||
var embedCode = document.querySelector("#embed-code").value;
|
||||
window.parent.postMessage(embedCode);
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
BIN
tinymce/gear.ico
BIN
tinymce/gear.ico
Binary file not shown.
Before Width: | Height: | Size: 1.1 KiB |
|
@ -14,13 +14,9 @@ module.exports = {
|
|||
},
|
||||
{
|
||||
test: /\.svg$/,
|
||||
exclude: /node_modules/,
|
||||
use: {
|
||||
loader: 'svg-react-loader',
|
||||
options: {
|
||||
jsx: true,
|
||||
},
|
||||
},
|
||||
issuer: /\.tsx?$/,
|
||||
use: [ '@svgr/webpack', 'url-loader' ],
|
||||
type: 'javascript/auto',
|
||||
},
|
||||
{
|
||||
test: /\.scss$/,
|
||||
|
|
Loading…
Reference in New Issue