commit 1426db528b838f67fb13914aa6f6daec006e5950 Author: Michael Thomas Date: Tue Jun 15 09:41:50 2021 -0400 Initial commit diff --git a/api.php b/api.php new file mode 100755 index 0000000..d8d27c1 --- /dev/null +++ b/api.php @@ -0,0 +1,64 @@ + + + + +EOF; + } + + // Builds Cognito module embed script + public static function get_embed_script($key, $module) { + $base = self::$servicesBase; + return <<< EOF +
+ + +
+EOF; + } +} + +?> \ No newline at end of file diff --git a/cogicon.ico b/cogicon.ico new file mode 100755 index 0000000..62b50ba Binary files /dev/null and b/cogicon.ico differ diff --git a/gear.ico b/gear.ico new file mode 100755 index 0000000..316b1b4 Binary files /dev/null and b/gear.ico differ diff --git a/plugin.php b/plugin.php new file mode 100755 index 0000000..7006989 --- /dev/null +++ b/plugin.php @@ -0,0 +1,188 @@ + 'renderCognitoShortcode', + 'cognito' => 'renderCognitoShortcode', + 'CognitoForms' => 'renderCognitoFormsShortcode', + 'cognitoforms' => 'renderCognitoFormsShortcode' + ); + + // Entrypoint + public function __construct() { + $this->addActions(self::$actions); + $this->addShortcodes(self::$shortcodes); + } + + // Initialize plug-in + 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'); + } + + // Add tinyMCE plug-in + if(get_user_option('rich_editing') == 'true') { + $this->addfilters(array( + 'mce_buttons', + 'mce_external_plugins' + )); + } + } + + // Register required scripts + public function wp_enqueue_scripts() { + wp_enqueue_script('jquery'); + } + + // Ajax callback to allow fetching of API keys based on session token + public function wp_ajax_fetch_api_keys() { + $organization = CognitoAPI::get_organization($_POST['token']); + + if (!is_null($organization)) { + delete_option('cognito_api_key'); + delete_option('cognito_admin_key'); + delete_option('cognito_public_key'); + delete_option('cognito_organization'); + + update_option('cognito_api_key', $organization->apiKey); + update_option('cognito_admin_key', $organization->adminKey); + update_option('cognito_public_key', $organization->publicKey); + update_option('cognito_organization', $organization->code); + } + + die; + } + + // Ajax callback to allow fetching of forms for a given organization + public function wp_ajax_get_forms() { + $api_key = get_option('cognito_api_key'); + + if ($api_key) { + $forms = CognitoAPI::get_forms($api_key); + + echo $forms; + } + + die; + } + + // Initialize administration menu (left-bar) + public function admin_menu() { + add_menu_page('Cognito Forms', 'Cognito Forms', 'manage_options', 'Cognito', array($this, 'main_page'), '../wp-content/plugins/cognito-forms/cogicon.ico'); + 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')); + } + + // Called when a 'Cognito' shortcode is encountered, renders embed script + public function renderCognitoShortcode($atts, $content = null, $code = '') { + // Default to key setting, unless overridden in shortcode (allows for modules from multiple orgs) + $key = empty($atts['key']) ? get_option('cognito_public_key') : $atts['key']; + if (empty($atts['module']) || empty($atts['key'])) return ''; + + return CognitoAPI::get_embed_script($key, $atts['module']); + } + + // Called when a 'CognitoForms' shortcode is encountered, renders form embed script + public function renderCognitoFormsShortcode($atts, $content = null, $code = '') { + // Default to key setting, unless overridden in shortcode (allows for modules from multiple orgs) + $key = empty($atts['key']) ? get_option('cognito_public_key') : $atts['key']; + if (empty($atts['id']) || empty($key)) return ''; + + return CognitoAPI::get_form_embed_script($key, $atts['id']); + } + + // Entrypoint for Cognito Forms access + public function main_page() { + include 'tmpl/main.php'; + } + + public function options_page() { + include 'tmpl/options.php'; + } + + // Set up tinyMCE buttons + public function mce_buttons($buttons) { + array_push($buttons, '|', 'cognito'); + return $buttons; + } + + // Initialize tinyMCE plug-in + public function mce_external_plugins($plugins) { + $plugins['cognito'] = plugin_dir_url( __FILE__ ) . 'tinymce/plugin.js'; + return $plugins; + } + + // Registers plug-in actions + private function addActions($actions) { + foreach($actions as $action) + add_action($action, array($this, $action)); + } + + // Registers shortcodes + private function addShortcodes($shortcodes) { + foreach($shortcodes as $tag => $func) + add_shortcode($tag, array($this, $func)); + } + + // Registers tinyMCE filters + private function addFilters($filters) { + foreach($filters as $filter) + add_filter($filter, array($this, $filter)); + } +} + +new Cognito_Plugin; +?> \ No newline at end of file diff --git a/readme.txt b/readme.txt new file mode 100755 index 0000000..4937859 --- /dev/null +++ b/readme.txt @@ -0,0 +1,93 @@ +=== Cognito Forms === +Contributors: cognitoapps +Donate link: https://www.cognitoforms.com +Tags: form, forms, cognito, cognito forms, create form, create forms, form builder, form creator, form generator, html form, online form, online form builder, online forms, registration, survey, surveys, web form, web forms, embed, anti-spam, email form, email, responsive, payment +Requires at least: 3.5 +Tested up to: 5.6 +Stable tag: 1.1.8 +License: GPLv2 or later +License URI: http://www.gnu.org/licenses/gpl-2.0.html + +Create responsive contact forms, order forms, registration forms and more. For free and without ever leaving WordPress. + +== Description == +Basic or advanced, we have all the features you need to quickly create powerful online forms. + +FREE Features: +----------- + +[Unlimited Forms & Fields](https://www.cognitoforms.com/features/unlimited-forms-fields) +Collect all the data you need, no matter what - make as many forms as you want, with as many fields as you want. +[Calculations](https://www.cognitoforms.com/features/calculations) +Let us do the math for you - build forms with powerful calculations that can total costs, compare dates and so much more. +[Conditional Logic](https://www.cognitoforms.com/features/conditional-logic) +Take each of your users on a unique path through your forms and control what they see with Conditional Logic. +[Countries, Languages & Currencies](https://www.cognitoforms.com/features/countries-languages-currencies) +18 languages. 121 countries. 137 currencies. Awesome forms. +[Email Notifications](https://www.cognitoforms.com/features/email-notifications) +Create custom autoresponder emails that include all the details of your customer's purchase or entry so they can review their order at any time. +[Entry Management](https://www.cognitoforms.com/features/entry-management) +Sort, filter, and organize your form submissions to help you smoothly run your business or organization. +[File Uploads](https://www.cognitoforms.com/features/file-uploads) +Capturing multiple files at once, setting file size and type limits - it all comes free with every single Cognito Forms account. +[Form Confirmations](https://www.cognitoforms.com/features/form-confirmations) +Create a personalized message to confirm a user's submission and allow them to review their order or entry data. +[Multi-Page Forms](https://www.cognitoforms.com/features/multi-page-forms) +Get more responses to your complex surveys and long forms with page breaks, progress bars and conditional pages. +[Payment](https://www.cognitoforms.com/features/payment) +Secure credit and debit card payment processing through Stripe. Or upgrade to use PayPal. +[Rating Scales](https://www.cognitoforms.com/features/rating-scales) +Give your customers an outlet for feedback right on your forms with customizable rating scales. +[Repeating Sections & Tables](https://www.cognitoforms.com/features/repeating-sections) +Collect as much or as little data as your customers can give, without any extra work or adding a lot of clutter. +[SPAM Prevention](https://www.cognitoforms.com/features/spam-prevention) +Keep your forms easy-to-use while eliminating rogue entries with our powerful, automatic spam prevention. +[Template Sharing](https://www.cognitoforms.com/features/template-sharing) +Made an awesome form? Share your form as a template so others can bask in your awesomeness. + +**Premium Features** +[Data Encryption](https://www.cognitoforms.com/features/data-encryption) +Keep your form data safe and sound. +[Document Merging](https://www.cognitoforms.com/features/document-merging) +Create PDF and Word docs from your entry data, completely customized the way you want. +[Electronic Signatures](https://www.cognitoforms.com/features/electronic-signatures) +Collect signatures on every form and on any device. +[Entry Sharing](https://www.cognitoforms.com/features/entry-sharing) +Give your users the ability to update their entries even after they've already been submitted. +[HIPAA Compliance](https://www.cognitoforms.com/features/hipaa-compliance) +Easily create secure forms to engage with your patients and protect their data. +[Save & Resume](https://www.cognitoforms.com/features/save-resume) +Allow users to pick up right where they left off by saving their progress on partially completed form responses. +[Saved Entry Views](https://www.cognitoforms.com/features/entry-management#saved) +After you sort and filter your entry data, save those settings to create a unique entry view. + +Learn more at [cognitoforms.com](https://www.cognitoforms.com). + +== Installation == + +1. Install and activate the plugin through the "Plugins" menu in WordPress. +2. If you have not already done so, install and activate the "Classic Editor" plugin from the WordPress store. + +== Frequently Asked Questions == + += Is Cognito Forms cloud-hosted? = + +Yes, your forms and your submissions are securely stored in the cloud. + += How do I create a form? = + +In order to create a form, you need to create a Cognito Forms account through the plugin. Once you design your form, you can embed it onto a post or a page by using the Cognito Forms icon, the orange cog, that shows up on the editor toolbar. We'll automatically add the short code for you. + + +== Screenshots == + +1. After activation, the Cognito Forms plugin will appear in your menu. Click on the plugin to be taken to Cognito Forms. +2. Click on the menu icon in the upper right to log in or sign up. +3. Once logged in, build a new form from a template or from scratch. +4. Build your form and click "Save". +5. In your WordPress menu, add a new Page or Post. +6. In the editor, click on the orange Cog icon for Cognito Forms. +7. Select the form name from the drop down and click "Insert Form". +8. The plugin inserts the Cognito Forms short code for you. +9. Preview or post your new form! + diff --git a/screenshot-1.png b/screenshot-1.png new file mode 100755 index 0000000..527f917 Binary files /dev/null and b/screenshot-1.png differ diff --git a/screenshot-2.png b/screenshot-2.png new file mode 100755 index 0000000..7cffe26 Binary files /dev/null and b/screenshot-2.png differ diff --git a/screenshot-3.png b/screenshot-3.png new file mode 100755 index 0000000..dddc821 Binary files /dev/null and b/screenshot-3.png differ diff --git a/screenshot-4.png b/screenshot-4.png new file mode 100755 index 0000000..474b894 Binary files /dev/null and b/screenshot-4.png differ diff --git a/screenshot-5.png b/screenshot-5.png new file mode 100755 index 0000000..29bbde8 Binary files /dev/null and b/screenshot-5.png differ diff --git a/screenshot-6.png b/screenshot-6.png new file mode 100755 index 0000000..41868a2 Binary files /dev/null and b/screenshot-6.png differ diff --git a/screenshot-7.png b/screenshot-7.png new file mode 100755 index 0000000..fcdd181 Binary files /dev/null and b/screenshot-7.png differ diff --git a/screenshot-8.png b/screenshot-8.png new file mode 100755 index 0000000..91f2a73 Binary files /dev/null and b/screenshot-8.png differ diff --git a/screenshot-9.png b/screenshot-9.png new file mode 100755 index 0000000..cab24ca Binary files /dev/null and b/screenshot-9.png differ diff --git a/tinymce/cogicon.ico b/tinymce/cogicon.ico new file mode 100755 index 0000000..62b50ba Binary files /dev/null and b/tinymce/cogicon.ico differ diff --git a/tinymce/dialog.php b/tinymce/dialog.php new file mode 100755 index 0000000..dc95308 --- /dev/null +++ b/tinymce/dialog.php @@ -0,0 +1,103 @@ + + + + + + + + + + Cognito Forms + + + + + + + + + \ No newline at end of file diff --git a/tinymce/gear.ico b/tinymce/gear.ico new file mode 100755 index 0000000..316b1b4 Binary files /dev/null and b/tinymce/gear.ico differ diff --git a/tinymce/plugin.js b/tinymce/plugin.js new file mode 100755 index 0000000..72198b5 --- /dev/null +++ b/tinymce/plugin.js @@ -0,0 +1,24 @@ +(function(){ + tinymce.create('tinymce.plugins.cognito', { + init : function(ed, url) { + ed.addCommand('cognito_embed_window', function() { + ed.windowManager.open({ + file : url + '/dialog.php', + width : 400, + height : 160, + inline: 1 + }, { plugin_url : url, ajax_url: ajaxurl }); + }); + + ed.addButton('cognito', { + title : 'Cognito Forms', + cmd : 'cognito_embed_window', + image : url + '/cogicon.ico' + }); + } + }); + + tinymce.PluginManager.add('cognito', tinymce.plugins.cognito); + +})() + diff --git a/tmpl/main.php b/tmpl/main.php new file mode 100755 index 0000000..1bd8f4a --- /dev/null +++ b/tmpl/main.php @@ -0,0 +1,81 @@ + + + + + + + diff --git a/tmpl/options.php b/tmpl/options.php new file mode 100755 index 0000000..d71e710 --- /dev/null +++ b/tmpl/options.php @@ -0,0 +1,29 @@ +

Cognito Forms

+ +
+ + + + + + + + + + + + + + + + + + + +
API Key
Admin API Key
Public API Key
Organization Code
+ +

+ +

+ +
\ No newline at end of file