Compare commits

..

30 Commits

Author SHA1 Message Date
8e0cfdac2f Remove admin sidebar page 2022-04-15 12:57:12 -04:00
39c65dcbce Update readme.txt 2022-04-15 12:45:08 -04:00
7b06e0226b Add docker-compose.yml 2022-03-30 11:31:44 -04:00
1e0ddad379 Improve classic editor support 2022-03-30 11:03:12 -04:00
3ea79e669c Fix filters for tinymce plugin 2022-03-20 23:01:10 -04:00
9662a50022 Update screenshots 2022-03-06 15:18:26 -05:00
20a2fa92a9 Fix select dialog sizing 2022-02-26 15:41:59 -05:00
23a23f7f56 Include cogicon file in production builds 2022-02-19 17:34:29 -05:00
23e8bcec59 Fix baseUrl 2022-02-19 17:34:16 -05:00
88b93868e4 Remove unnecessary import 2022-02-19 16:44:22 -05:00
45f8cfafdd Simplify zip file build pipeline 2022-02-19 16:44:11 -05:00
d9888842b6 Update CogIcon for redesign 2022-02-19 16:43:54 -05:00
9a72704d02 Add LICENSE 2022-02-18 13:58:26 -05:00
78d3acb74c Store Cognito base url solely in api.php 2022-02-18 13:48:59 -05:00
6a5c99e483 PHP formatting fixes 2022-02-17 21:35:02 -05:00
054ceef45e Update "new form" block action 2022-02-17 21:34:14 -05:00
5c96a82651 Update types for @wordpress/components 2022-02-17 20:54:37 -05:00
f17d2dfa42 Fixes for Gutenberg modal 2022-02-17 20:54:23 -05:00
69ec05cd6a Bring back support for legacy shortcodes 2022-02-14 16:55:39 -05:00
ff1f452e61 Fix asset importing 2022-02-14 16:54:46 -05:00
b142f57648 Update dependencies 2022-02-14 16:48:40 -05:00
d7ee54fcec Update and simplify build process 2022-02-10 18:01:32 -05:00
748af6a14f Improve typings 2022-02-06 22:11:00 -05:00
42a2dced76 Update eslint configuration 2022-02-06 22:01:32 -05:00
dd0222fb19 Rename plugin.php to comply with WordPress best practices 2022-02-06 22:00:54 -05:00
1f21469bce Merge branch 'main' of https://git.thomasfamily.duckdns.org/cognito-forms/cognitoforms-wordpress 2022-02-02 11:33:00 -05:00
85973c58ed Update preview logic, render select dialog conditionally 2022-02-02 09:42:30 -05:00
4b9095782d Update header comments 2022-02-02 09:41:34 -05:00
2ebc710272 Remove unnecessary prop 2022-01-30 15:52:00 -05:00
33a36d8a52 Add embed mode selector 2022-01-30 15:51:32 -05:00
38 changed files with 2916 additions and 998 deletions

View File

@@ -1,9 +0,0 @@
src
node_modules
README.md
.*
package.json
yarn.lock
webpack.config.js
tsconfig.json

View File

@@ -1,3 +1,6 @@
// Implements WordPress JS Coding Standards
// https://developer.wordpress.org/coding-standards/wordpress-coding-standards/javascript/
{
"root": true,
"parser": "@typescript-eslint/parser",
@@ -10,7 +13,8 @@
"extends": [
"plugin:react/recommended",
"plugin:jsx-a11y/recommended",
"plugin:jest/recommended"
"plugin:jest/recommended",
"plugin:@typescript-eslint/recommended"
],
"env": {
"browser": false,
@@ -142,13 +146,15 @@
"message": "Translate function arguments must be string literals."
}
],
"no-shadow": "error",
"no-shadow": "off",
"@typescript-eslint/no-shadow": ["error"],
"no-undef": "error",
"no-undef-init": "error",
"no-unreachable": "error",
"no-unsafe-negation": "error",
"no-unused-expressions": "error",
"no-unused-vars": "error",
"no-unused-vars": "off",
"@typescript-eslint/no-unused-vars": ["error"],
"no-useless-computed-key": "error",
"no-useless-constructor": "error",
"no-useless-return": "error",

53
.github/workflows/release.yml vendored Normal file
View File

@@ -0,0 +1,53 @@
name: release
on: [ push ]
jobs:
release-to-github:
name: Release to GitHub
runs-on: ubuntu-latest
if: contains(github.ref, 'main')
steps:
- name: Checkout repository
uses: actions/checkout@v2
with:
ref: main
- name: Check if version has changed
uses: EndBug/version-check@v1
id: check
- name: Version update detected
if: steps.check.outputs.changed == 'true'
run: 'echo "Version change found! New version: ${{ steps.check.outputs.version }} (${{ steps.check.outputs.type }})"'
- name: Install dependencies
if: steps.check.outputs.changed == 'true'
run: npm install
- name: Build plugin zip
if: steps.check.outputs.changed == 'true'
run: npm run create-zip
- name: Create release
if: steps.check.outputs.changed == 'true'
uses: actions/create-release@v1
id: create_release
with:
draft: false
prerelease: false
release_name: ${{ steps.check.outputs.version }}
tag_name: ${{ github.ref }}
body_path: CHANGELOG.md
env:
GITHUB_TOKEN: ${{ github.token }}
- name: Upload artifact
if: steps.check.outputs.changed == 'true'
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ github.token }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./cognito-forms-${{ steps.check.outputs.version }}.zip
asset_name: cognito-forms-${{ steps.check.outputs.version }}.zip
asset_content_type: application/zip

1
.gitignore vendored
View File

@@ -1,2 +1,3 @@
node_modules
dist/
*.zip

339
LICENSE Normal file
View File

@@ -0,0 +1,339 @@
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Lesser General Public License instead.) You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must show them these terms so they know their
rights.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.
You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.
c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.
In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable. However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.
If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.
5. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.
10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program 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 Street, Fifth Floor, Boston, MA 02110-1301 USA.
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) year name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, the commands you use may
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.
<signature of Ty Coon>, 1 April 1989
Ty Coon, President of Vice
This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License.

51
api.php Normal file
View File

@@ -0,0 +1,51 @@
<?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
if ( !class_exists('CognitoAPI') ) {
class CognitoAPI {
public static $formsBase = 'https://www.cognitoforms.com';
// Convert MS GUID to Short GUID
private static function guid_to_short_guid($guid) {
$guid_byte_order = [ 3,2,1,0,5,4,7,6,8,9,10,11,12,13,14,15 ];
$guid = preg_replace( "/[^a-zA-Z0-9]+/", "", $guid );
$hex = "";
for ( $i = 0; $i < 16; $i++ )
$hex .= substr( $guid, 2 * $guid_byte_order[$i], 2 );
$bin = hex2bin( $hex );
$encoded = base64_encode( $bin );
$encoded = str_replace( "/", "_", $encoded );
$encoded = str_replace( "+", "-", $encoded );
$encoded = substr ( $encoded, 0, 22 );
return $encoded;
}
// Builds form embed script
public static function get_form_embed_script( $public_key, $formId ) {
$base = self::$formsBase;
$public_short_guid = self::guid_to_short_guid( $public_key );
return <<< EOF
<script src="{$base}/f/seamless.js" data-key="{$public_short_guid}" data-form="{$formId}"></script>
EOF;
}
}
}
?>

View File

@@ -1,16 +1,16 @@
trigger:
- main
- main
pool:
vmImage: 'ubuntu-latest'
vmImage: 'ubuntu-latest'
steps:
- script: yarn install
displayName: 🛠️ Install Dependencies
- script: yarn build
displayName: 🚀 Build Plugin
- task: PublishPipelineArtifact@1
displayName: 📦 Create Artifact
inputs:
targetPath: $(System.DefaultWorkingDirectory)
artifactName: CognitoFormsPlugin
- script: yarn install
displayName: 🛠️ Install Dependencies
- script: yarn build
displayName: 🚀 Build Plugin
- task: PublishPipelineArtifact@1
displayName: 📦 Create Artifact
inputs:
targetPath: $(System.DefaultWorkingDirectory)
artifactName: CognitoFormsPlugin

View File

@@ -1 +1,8 @@
<svg id="icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 18 18"><defs><style>.cls-1{fill:#d85427;}.cls-2{fill:#fff;}</style></defs><g id="cogicon"><path id="cogicon__cog" class="cls-1" d="M5,14.19l1.54-1.06a4.89,4.89,0,0,0,1.31.56l.33,1.81H9.81l.33-1.86a5.38,5.38,0,0,0,1.34-.54L13,14.15,14.16,13,13.1,11.47a5.46,5.46,0,0,0,.57-1.34L15.5,9.8V8.17l-1.83-.32a5.21,5.21,0,0,0-.56-1.33L14.16,5,13,3.83,11.48,4.91a8.28,8.28,0,0,0-1.32-.54L9.82,2.5H8.19L7.85,4.37a4.87,4.87,0,0,0-1.3.53L5,3.84,3.87,4.92l1,1.64a4.53,4.53,0,0,0-.54,1.31L2.5,8.2V9.84l1.86.34a5,5,0,0,0,.55,1.3L3.87,13Z"/><path id="cogicon__c" class="cls-2" d="M8,10.1a1.33,1.33,0,0,0,1,.42,1.37,1.37,0,0,0,1-.37,1.51,1.51,0,0,0,.33-.56l1.54.29.5.11s-.15.41-.15.41a3.84,3.84,0,0,1-.83,1.21A3.23,3.23,0,0,1,9,12.48,3.4,3.4,0,0,1,5.56,9.16V9a3.34,3.34,0,0,1,1-2.49,3.38,3.38,0,0,1,2.51-1,3.2,3.2,0,0,1,2.43,1,3.15,3.15,0,0,1,.67,1,2.54,2.54,0,0,1,.19.59l-2,.36A1.33,1.33,0,0,0,9,7.49a1.34,1.34,0,0,0-1,.43A1.6,1.6,0,0,0,7.57,9,1.53,1.53,0,0,0,8,10.1Z"/></g></svg>
<?xml version="1.0" encoding="UTF-8"?>
<svg fill="none" version="1.1" viewBox="0 0 40 40" xmlns="http://www.w3.org/2000/svg">
<title>cogicon</title>
<g id="cogicon">
<path id="cogicon__cog" d="m20.002 0c-1.3231 0-2.6464 0.15454-2.6496 0.15491l-1.1226 4.8043a15.412 15.412 0 0 0-4.1968 1.7383l-4.1907-2.6034s-1.0463 0.82704-1.9837 1.7644c-0.93634 0.93737-1.7644 1.9817-1.7644 1.9817l2.6034 4.1927a15.412 15.412 0 0 0-1.7383 4.1947l-4.8043 1.1226s-0.15491 1.327-0.15491 2.6516 0.15491 2.6476 0.15491 2.6476l4.8043 1.1226a15.412 15.412 0 0 0 1.7383 4.1968l-2.6034 4.1907s0.82704 1.0463 1.7644 1.9837c0.93737 0.93634 1.9817 1.7644 1.9817 1.7644l4.1927-2.6054a15.413 15.413 0 0 0 4.1947 1.7403l1.1226 4.8043s1.327 0.1529 2.6516 0.1529 2.6476-0.1529 2.6476-0.1529l1.1226-4.8043a15.411 15.411 0 0 0 4.1968-1.7403l4.1907 2.6054s1.0463-0.82704 1.9837-1.7644c0.93634-0.93737 1.7644-1.9817 1.7644-1.9817l-2.6054-4.1927a15.411 15.411 0 0 0 1.7403-4.1968l4.8043-1.1226s0.1529-1.3229 0.1529-2.6476-0.1529-2.6496-0.1529-2.6496l-4.8043-1.1226a15.411 15.411 0 0 0-1.7403-4.1968l2.6054-4.1907a26.133 26.133 0 0 0-1.7644-1.9837c-0.93737-0.93634-1.9817-1.7644-1.9817-1.7644l-4.1927 2.6034c-1.2886-0.77359-2.7001-1.3643-4.1968-1.7383l-1.1226-4.8043s-1.3229-0.15491-2.6476-0.15491zm-0.09053 8.6832a10.861 10.861 0 0 1 6.1422 1.8851 11.066 11.066 0 0 1 3.9714 4.8245c0.08344 0.2225 0.16805 0.41728 0.25148 0.63978l-5.6976 1.4687c-0.11125-0.24928-0.24923-0.4716-0.38829-0.6941a5.1009 5.1009 0 0 0-2.2493-1.857c-0.61186-0.25031-1.2808-0.38829-2.0018-0.38829a5.3646 5.3646 0 0 0-2.8629 0.88723 5.0958 5.0958 0 0 0-1.861 2.2473c-0.25031 0.60981-0.38829 1.2747-0.38829 1.9958a5.3399 5.3399 0 0 0 0.88925 2.8569 5.4306 5.4306 0 0 0 2.2774 1.8851 5.2472 5.2472 0 0 0 1.9998 0.38829 5.3636 5.3636 0 0 0 2.8629-0.88724 5.1885 5.1885 0 0 0 1.8067-2.1346l5.6956 1.525c-0.33272 0.91574-0.75014 1.7462-1.2775 2.5229a11.078 11.078 0 0 1-4.8365 3.9654c-1.3329 0.55521-2.7764 0.85907-4.2772 0.85907-2.2775 0-4.3891-0.69229-6.1402-1.8851a11.066 11.066 0 0 1-3.9734-4.8245c-0.55521-1.3309-0.86108-2.7735-0.86108-4.2712a10.812 10.812 0 0 1 1.8891-6.1282 11.077 11.077 0 0 1 4.8345-3.9674c1.3051-0.55418 2.7496-0.85776 4.1948-0.91339z" fill="#000" />
</g>
</svg>

Before

Width:  |  Height:  |  Size: 1.0 KiB

After

Width:  |  Height:  |  Size: 2.2 KiB

206
cognito-forms.php Normal file
View File

@@ -0,0 +1,206 @@
<?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
*/
/**
* Plugin Name: Cognito Forms
* Plugin URI: http://wordpress.org/plugins/cognito-forms/
* Description: Cognito Forms is a free online form builder that integrates seamlessly with WordPress. Create contact forms, registrations forms, surveys, and more!
* Version: 2.0.0
* Author: Cognito Apps
* Author URI: https://www.cognitoforms.com
* License: GPL v2 or later
* License URI: https://www.gnu.org/licenses/gpl-2.0.html
*/
// Exit if accessed directly.
if ( !defined( 'ABSPATH' ) ) {
exit;
}
/**
* The Plugin
*/
if ( !class_exists( 'CognitoFormsPlugin' ) ) {
require_once dirname( __FILE__ ) . '/api.php';
class CognitoFormsPlugin {
// Initialization actions
private static $actions = array(
'admin_init',
'init',
'wp_ajax_cognito_tinymce_dialog'
);
// Supported shortcodes
private static $shortcodes = array(
'CognitoForms' => 'render_cognito_shortcode',
'cognitoforms' => 'render_cognito_shortcode'
);
// Registers plug-in actions
private function add_actions( $actions ) {
foreach ( $actions as $action )
add_action( $action, array( $this, $action ) );
}
// Registers shortcodes
private function add_shortcodes( $shortcodes ) {
foreach ( $shortcodes as $tag => $func )
add_shortcode( $tag, array( $this, $func ) );
}
// Checks if an option exists in the database
private function option_exists( $option_name, $site_wide = false ) {
global $wpdb;
return $wpdb->query( $wpdb->prepare( "SELECT * FROM ". ($site_wide ? $wpdb->base_prefix : $wpdb->prefix). "options WHERE option_name ='%s' LIMIT 1", $option_name ) );
}
// Removes a list of options if they exist
private function remove_options( $options ) {
foreach ($options as $option) {
if ( $this->option_exists( $option ) ) {
delete_option( $option );
}
}
}
// Entrypoint
public function __construct() {
$this->add_actions( self::$actions );
$this->add_shortcodes( self::$shortcodes );
}
public function init() {
// Initialize Gutenberg Block
$this->block_init();
// Add support for oEmbed
$this->oembed_init();
}
// Initialize plug-in
public function admin_init() {
if( !current_user_can( 'edit_posts' ) && !current_user_can( 'edit_pages' ) )
return;
add_option( 'cognito_public_key' );
// Remove old API keys from the database
$this->remove_options( array(
'cognito_api_key',
'cognito_admin_key',
'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_public_key' );
}
// Initialize TinyMCE Plugin
$this->tinymce_init();
}
// Initialize block
public function block_init() {
$asset_file = include( plugin_dir_path( __FILE__ ) . 'dist/index.asset.php' );
// Register global block styles
wp_register_style(
'cognito-block-global-css', // Handle.
plugins_url( 'dist/style-main.css', __FILE__ ), // Public CSS
is_admin() ? array( 'wp-editor' ) : null, // Dependency to include the CSS after it.
$asset_file['version']
);
// Register block editor script for backend
wp_register_script(
'cognito-block-editor-js',
plugins_url( 'dist/index.js', __FILE__ ),
$asset_file['dependencies'],
$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.
plugins_url( 'dist/main.css', __FILE__ ), // Block editor CSS.
array( 'wp-edit-blocks' ), // Dependency to include the CSS after it.
$asset_file['version']
);
register_block_type(
'cognito-forms/cognito-embed', array(
// Enqueue global block styles on both frontend and backend
'style' => 'cognito-block-global-css',
// Enqueue block js in the editor only
'editor_script' => 'cognito-block-editor-js',
// Enqueue editor block styles in the editor only
'editor_style' => 'cognito-block-editor-css'
)
);
}
// Initialize classic editor (TinyMCE)
public function tinymce_init() {
if ( get_user_option( 'rich_editing' ) == 'true' ) {
add_filter( 'mce_buttons', array( $this, 'tinymce_buttons' ) );
add_filter( 'mce_external_plugins', array( $this, 'tinymce_external_plugins' ) );
}
}
// Set up TinyMCE buttons
public function tinymce_buttons( $buttons ) {
array_push($buttons, '|', 'cognito');
return $buttons;
}
// Set up TinyMCE plug-in
public function tinymce_external_plugins( $plugin_array ) {
$plugin_array['cognito_mce_plugin'] = plugins_url( '/tinymce/plugin.js', __FILE__ );
return $plugin_array;
}
public function wp_ajax_cognito_tinymce_dialog() {
include 'tinymce/dialog.php';
wp_die();
}
// Called when a 'CognitoForms' shortcode is encountered, renders form embed script
public function render_cognito_shortcode( $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'] );
}
// Add support for oEmbed using the generic Gutenberg Embed block
public function oembed_init() {
wp_oembed_add_provider( '#https?://(www\.)?cognitoforms\.com/.*#i', 'https://www.cognitoforms.com/f/oembed/', true );
}
}
new CognitoFormsPlugin;
}

34
docker-compose.yml Normal file
View File

@@ -0,0 +1,34 @@
version: "3.9"
services:
db:
image: mysql:5.7
volumes:
- db_data:/var/lib/mysql
restart: always
environment:
MYSQL_ROOT_PASSWORD: somewordpress
MYSQL_DATABASE: wordpress
MYSQL_USER: wordpress
MYSQL_PASSWORD: wordpress
wordpress:
depends_on:
- db
image: wordpress:5.9.0
volumes:
- wordpress_data:/var/www/html
- .:/var/www/html/wp-content/plugins/cognito-forms:ro
ports:
- "8085:80"
restart: always
environment:
WORDPRESS_DB_HOST: db:3306
WORDPRESS_DB_USER: wordpress
WORDPRESS_DB_PASSWORD: wordpress
WORDPRESS_DB_NAME: wordpress
WORDPRESS_DEBUG: "true"
volumes:
db_data: {}
wordpress_data: {}

20
gulpfile.esm.js Normal file
View File

@@ -0,0 +1,20 @@
import { src, dest } from 'gulp';
import zip from 'gulp-zip';
import pjson from './package.json';
export default function() {
return src( [
'dist/**/*',
'templates/**/*',
'tinymce/**/*',
'*.php',
'cogicon.svg',
'LICENSE',
'readme.txt',
'screenshot*.png',
], {
base: './',
} )
.pipe( zip( `cognito-forms-${ pjson.version }.zip` ) )
.pipe( dest( '.' ) );
}

View File

@@ -4,12 +4,10 @@
"private": true,
"main": "src/blocks.ts",
"scripts": {
"build:js": "webpack --mode=production",
"build:sass": "sass src/styles:dist",
"build": "npm run build:js && npm run build:sass",
"watch:js": "webpack --mode=development --watch",
"watch:sass": "sass -w src/styles:dist",
"start": "shx rm -rf dist/* && concurrently -n \"JS,CSS\" -c \"bgBlue.bold,bgMagenta.bold\" --kill-others \"npm run watch:js\" \"wait-on dist/index.js && npm run watch:sass\""
"lint": "wp-scripts lint-js 'src/**/*{.js,.jsx,.ts,.tsx}'",
"build": "webpack --mode=production",
"start": "webpack --mode=development --watch",
"create-zip": "npm run build && gulp"
},
"browserslist": {
"production": [
@@ -25,34 +23,38 @@
},
"dependencies": {
"@types/classnames": "^2.2.10",
"@types/node": "^17.0.8",
"@types/react": "^17.0.38",
"@types/node": "^17.0.18",
"@types/react": "^17.0.39",
"@types/react-dom": "^17.0.11",
"@types/wordpress__block-editor": "^6.0.4",
"@types/wordpress__block-editor": "^6.0.5",
"@types/wordpress__blocks": "^9.1.1",
"@wordpress/block-editor": "^8.0.13",
"@wordpress/blocks": "^11.1.5",
"@wordpress/i18n": "^4.2.4",
"@wordpress/icons": "^6.1.1",
"@types/wordpress__components": "^19.3.0",
"@wordpress/block-editor": "^8.1.1",
"@wordpress/blocks": "^11.2.1",
"@wordpress/components": "^19.4.0",
"@wordpress/i18n": "^4.3.1",
"@wordpress/icons": "^6.3.0",
"@wordpress/scripts": "^19.2.2",
"classnames": "^2.2.6",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-scripts": "5.0.0",
"sass-loader": "^12.5.0",
"style-loader": "^3.3.1",
"svg-react-loader": "^0.4.6",
"ts-loader": "^9.2.6",
"typescript": "~4.5.4",
"webpack": "^5.66.0",
"webpack-cli": "^4.9.1"
"typescript": "~4.5.5",
"url-loader": "^4.1.1",
"webpack": "^5.68.0",
"webpack-cli": "^4.9.2"
},
"devDependencies": {
"@typescript-eslint/eslint-plugin": "^5.10.0",
"@typescript-eslint/parser": "^5.10.0",
"concurrently": "^7.0.0",
"eslint-plugin-jest": "^25.7.0",
"prettier": "^2.0.5",
"sass": "^1.48.0",
"shx": "^0.3.4",
"wait-on": "^6.0.0"
"@typescript-eslint/eslint-plugin": "^5.12.0",
"@typescript-eslint/parser": "^5.12.0",
"eslint-plugin-jest": "^26.1.0",
"esm": "^3.2.25",
"gulp": "^4.0.2",
"gulp-zip": "^5.1.0",
"prettier": "^2.0.5"
}
}

View File

@@ -1,161 +0,0 @@
<?php
/*
Plugin Name: Cognito Forms
Plugin URI: http://wordpress.org/plugins/cognito-forms/
Description: Cognito Forms is a free online form builder that integrates seamlessly with WordPress. Create contact forms, registrations forms, surveys, and more!
Version: 2.0.0
Author: Cognito Apps
Author URI: https://www.cognitoforms.com
*/
/**
* 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
*/
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* The Plugin
*/
if ( !class_exists('CognitoFormsPlugin') ) {
class CognitoFormsPlugin {
// Initialization actions
private static $actions = array(
'admin_init',
'admin_menu',
'init'
);
// Registers plug-in actions
private function addActions($actions) {
foreach($actions as $action)
add_action($action, array($this, $action));
}
// Registers plug-in filters
private function addFilters($filters) {
foreach($filters as $filter)
add_filter($filter, array($this, $filter));
}
// Entrypoint
public function __construct() {
$this->addActions(self::$actions);
}
public function init() {
// Initialize Gutenberg Block
$this->block_init();
// Add support for oEmbed
$this->oembed_init();
}
// Initialize plug-in
public function admin_init() {
if(!current_user_can('edit_posts') && !current_user_can('edit_pages')) return;
// Initialize TinyMCE Plugin
$this->tinymce_init();
}
// Initialize block
public function block_init() {
$dir = dirname( __FILE__ );
$asset_file = include( plugin_dir_path( __FILE__ ) . 'dist/index.asset.php');
// Register global block styles
wp_register_style(
'cognito-block-global-css', // Handle.
plugins_url( 'dist/style.css', __FILE__ ),
is_admin() ? array( 'wp-editor' ) : null, // Dependency to include the CSS after it.
null // filemtime( plugin_dir_path( __DIR__ ) . 'dist/blocks.style.build.css' ) // Version: File modification time.
);
// Register block editor script for backend
wp_register_script(
'cognito-block-editor-js',
plugins_url( 'dist/index.js', __FILE__ ),
$asset_file['dependencies'],
$asset_file['version']
);
// Register block editor styles for backend.
wp_register_style(
'cognito-block-editor-css', // Handle.
plugins_url( 'dist/editor.css', __FILE__ ), // Block editor CSS.
array( 'wp-edit-blocks' ), // Dependency to include the CSS after it.
null // filemtime( plugin_dir_path( __DIR__ ) . 'dist/blocks.editor.build.css' ) // Version: File modification time.
);
register_block_type(
'cognito-forms/cognito-embed', array(
// Enqueue global block styles on both frontend and backend
'style' => 'cognito-block-global-css',
// Enqueue block js in the editor only
'editor_script' => 'cognito-block-editor-js',
// Enqueue editor block styles in the editor only
'editor_style' => 'cognito-block-editor-css'
) );
}
// Initialize classic editor (TinyMCE)
public function tinymce_init() {
if(get_user_option('rich_editing') == 'true') {
$this->addFilters(array(
'mce_buttons',
'mce_external_plugins'
));
}
}
// Set up TinyMCE buttons
public function mce_buttons( $buttons ) {
array_push($buttons, '|', 'cognito');
return $buttons;
}
// Initialize TinyMCE plug-in
public function mce_external_plugins( $plugin_array ) {
$plugin_array['cognito_mce_plugin'] = plugins_url( '/tinymce/plugin.js', __FILE__ );
return $plugin_array;
}
// 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' ) );
}
// Entrypoint for Cognito Forms access
public function main_page() {
include 'templates/main.php';
}
// Add support for oEmbed using the generic Gutenberg Embed block
public function oembed_init() {
wp_oembed_add_provider( '#https?://(www\.)?cognitoforms\.com/.*#i', 'https://www.cognitoforms.com/f/oembed/', true );
}
}
new CognitoFormsPlugin;
}

View File

@@ -1,93 +1,115 @@
=== 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!
=== 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.9.3
Stable tag: 2.0.0
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. With PCI, CCPA, and HIPAA compliance.
== Description ==
Cognito Forms is an easy-to-use online form builder that enables you to create everything from simple surveys to complex registration forms - no code required. Whether youre using a pre-made template or starting from scratch, you can create forms to help your organization in just a matter of minutes.
New to Cognito Forms? Watch a quick tutorial to get acquainted with the form builder, and learn how to create your first form!
[youtube https://www.youtube.com/watch?v=8lZ7cK29C9U]
== Online Payment ==
Accept online payments directly through your forms using Square, Stripe or PayPal. Whether youre collecting a simple online donation or processing complex multivariable transactions, you can do so easily on any of our plan levels.
Simply connect your payment account to begin doing business in minutes. These secure online transactions integrate directly into your forms to deliver a better experience both for you and your customers.
== Integrations ==
Increase the power, utility and functionality of your forms using native and third-party integrations. Its surprisingly simple.
Use Zapier, Microsoft Power Automate or Integromat to exchange data with thousands of applications. Create workflows and automatically trigger tasks directly from your form entries. And quickly set it all up using either no-code visual interfaces or JSON.
== Security & Compliance ==
Protect your customers, your organization and all the information you collect. Because, in todays online world, security comes first.
Quickly create additional protections for fields and forms. Set organizational controls by the individual form or folder. Manage access and account permissions. And stay compliant with HIPAA, GDPR, CCPA and other security regulations.
== Features ==
**Data Collection**
[Electronic Signatures](https://www.cognitoforms.com/product/electronic-signatures)
[File Uploads](https://www.cognitoforms.com/product/file-uploads)
[Multi-Page Forms & Page Breaks](https://www.cognitoforms.com/product/multi-page-forms)
[Rating Scales](https://www.cognitoforms.com/product/rating-scales)
[Repeating Sections & Tables](https://www.cognitoforms.com/product/repeating-sections-tables)
[Save & Resume](https://www.cognitoforms.com/product/save-resume)
[Style Customization](https://www.cognitoforms.com/product/style-customization)
**Data Management**
[Importing](https://www.cognitoforms.com/product/importing)
[Exporting](https://www.cognitoforms.com/product/exporting)
[Entry Sharing](https://www.cognitoforms.com/product/entry-sharing)
[Saved Entry Views](https://www.cognitoforms.com/product/saved-entry-views)
**Integrations**
[Google Analytics](https://www.cognitoforms.com/product/google-analytics)
[Microsoft Power Automate](https://www.cognitoforms.com/product/microsoft-power-automate)
[Zapier](https://www.cognitoforms.com/product/zapier)
[Make (formerly Integromat)](https://www.cognitoforms.com/product/integromat)
[JSON Webhooks](https://www.cognitoforms.com/product/json-webhooks)
**Logic & Automation**
[Calculations](https://www.cognitoforms.com/product/calculations)
[Conditional Logic](https://www.cognitoforms.com/product/conditional-logic)
[Quantity Limits](https://www.cognitoforms.com/product/quantity-limits)
[Lookup Field](https://www.cognitoforms.com/product/lookup-field)
[Notifications](https://www.cognitoforms.com/product/notifications)
[Document Generation](https://www.cognitoforms.com/product/document-generation)
**Online Payment**
[Stripe Payments](https://www.cognitoforms.com/product/stripe-payments)
[Card on File](https://www.cognitoforms.com/product/card-on-file)
[PayPal Payments](https://www.cognitoforms.com/product/paypal-payments)
[Square Payments](https://www.cognitoforms.com/product/square-payments)
**Security & Compliance**
[Two-Factor Authentication](https://www.cognitoforms.com/product/two-factor-authentication)
[Data Encryption](https://www.cognitoforms.com/product/data-encryption)
[Data Protection & Privacy](https://www.cognitoforms.com/product/data-protection-privacy)
[Folder Permissions](https://www.cognitoforms.com/product/folder-permissions)
[HIPAA Compliance](https://www.cognitoforms.com/product/hipaa-compliance)
[ADA Compliance](https://www.cognitoforms.com/product/ada-compliance)
== Installation ==
1. Upload `cognitoforms.zip` from the Upload section of the 'Plugins' menu in WordPress.
2. Activate the plugin through the 'Plugins' menu in WordPress.
== Frequently Asked Questions ==
= Is Cognito Forms cloud-hosted? =
Cognito Forms is a subscription-based service and we host all of the forms and data collected securely on the Microsoft Azure cloud platform, which is PCI (DSS) Level 1 and HIPAA compliant.
= 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.
= Now that I've built a form, can I receive a notification every time my form is submitted? =
Yes in fact, our forms default to sending an email notification to the email address belonging to the owner of the account.
You can further customize that email notification to be sent on behalf of your website domain, contain custom content, show details from the entry, or go to multiple email addresses.
== Screenshots ==
1. After activation, the Cognito Forms plugin will appear in your menu. Click on the plugin to be taken to Cognito Forms.
2. Once logged in, build a new form from a template or from scratch.
3. Open the page or post where you'd like to insert your form, then add the Cognito Forms block.
4. Select your form from the drop down and click "Embed".
5. The plugin automatically embeds the form on your site.
6. Preview or publish to see your new form in action!

BIN
screenshot-1.png Executable file → Normal file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 94 KiB

After

Width:  |  Height:  |  Size: 382 KiB

BIN
screenshot-2.png Executable file → Normal file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 71 KiB

After

Width:  |  Height:  |  Size: 444 KiB

BIN
screenshot-3.png Executable file → Normal file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 105 KiB

After

Width:  |  Height:  |  Size: 277 KiB

BIN
screenshot-4.png Executable file → Normal file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 85 KiB

After

Width:  |  Height:  |  Size: 263 KiB

BIN
screenshot-5.png Executable file → Normal file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 94 KiB

After

Width:  |  Height:  |  Size: 792 KiB

BIN
screenshot-6.png Executable file → Normal file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 70 KiB

After

Width:  |  Height:  |  Size: 766 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 68 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 70 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 31 KiB

View File

@@ -1 +0,0 @@
<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>

Before

Width:  |  Height:  |  Size: 2.0 KiB

28
src/block.json Normal file
View File

@@ -0,0 +1,28 @@
{
"$schema": "https://schemas.wp.org/trunk/block.json",
"apiVersion": 2,
"name": "cognito-forms/cognito-embed",
"title": "Cognito Forms",
"description": "Easily build powerful forms.",
"category": "embed",
"supports": {
"html": false
},
"attributes": {
"formId": {
"type": "string"
},
"seamlessEmbedCode": {
"type": "string"
},
"iframeEmbedCode": {
"type": "string"
},
"ampEmbedCode": {
"type": "string"
},
"embedMode": {
"type": "number"
}
}
}

View File

@@ -7,20 +7,19 @@ import * as _ from 'lodash';
import { Spinner } from '@wordpress/components';
import { baseUrl } from '@/globals';
import { ReactComponent as CogIcon } from '@/assets/cogicon.svg';
import { ReactComponent as CogIcon } from '@/../cogicon.svg';
type PreviewProps = {
formId: string;
interface IPreviewProps {
embedCode: string;
};
}
type PreviewState = {
interface IPreviewState {
uniqueId: string;
loading: boolean;
};
}
class PreviewForm extends React.Component<PreviewProps, PreviewState> {
constructor( props: any ) {
class PreviewForm extends React.Component<IPreviewProps, IPreviewState> {
constructor( props: IPreviewProps ) {
super( props );
// Generate a unique identifier, so that the embed script can be identified
@@ -40,7 +39,7 @@ class PreviewForm extends React.Component<PreviewProps, PreviewState> {
}
// Force the embed script to load, which makes Iframes in the editor resize properly.
loadEmbedScript( callback?: Function ) {
loadEmbedScript( callback?: () => void ) {
const existingScript = document.getElementById( `cog-embed-script-${ this.state.uniqueId }` );
if ( ! existingScript ) {

View File

@@ -2,27 +2,17 @@
* WordPress dependencies
*/
import * as React from 'react';
import { Button, Modal, FocusableIframe } from '@wordpress/components';
import { Modal } from '@wordpress/components';
import { baseUrl } from '@/globals';
import { IForm } from '@/types';
type DialogProps = {
onSelectForm: Function;
};
type DialogState = {
isOpen: boolean;
};
class SelectDialog extends React.Component<DialogProps, DialogState> {
constructor( props: any ) {
super( props );
this.state = {
isOpen: false,
};
}
interface IDialogProps {
setOpen: ( val: boolean ) => void;
onSelectForm: ( form: IForm ) => void;
}
class SelectDialog extends React.Component<IDialogProps> {
componentDidMount() {
window.addEventListener( 'message', this.handlePostMessage, false );
}
@@ -32,32 +22,26 @@ class SelectDialog extends React.Component<DialogProps, DialogState> {
}
handlePostMessage = ( event: MessageEvent ) => {
if (event.origin === baseUrl && event.data.type === 'cog-form-selected') {
if ( event.origin === baseUrl && event.data.type === 'cog-form-selected' ) {
this.props.onSelectForm( event.data );
this.setState({ isOpen: false }); // Close Dialog
this.props.setOpen( false );
}
}
};
render() {
return (
<div>
<Button isPrimary={true} onClick={ () => this.setState( { isOpen: true } ) }>
Choose a form
</Button>
{ this.state.isOpen && (
<Modal
title="Cognito Forms"
className="cognito-modal"
onRequestClose={ () => this.setState( { isOpen: false } ) }
shouldCloseOnClickOutside={ false }
>
<FocusableIframe
style={ { width: '500px', height: '500px', display: 'block' } }
src={ `${ baseUrl }/integrations/cms` }
></FocusableIframe>
</Modal>
) }
</div>
<Modal
title="Cognito Forms"
className="cognito-modal"
onRequestClose={ () => this.props.setOpen( false ) }
shouldCloseOnClickOutside={ false }
>
<iframe
style={ { width: '500px', height: '100%', display: 'block' } }
src={ `${ baseUrl }/integrations/cms` }
title="Choose a Form"
></iframe>
</Modal>
);
}
}

View File

@@ -1,5 +1,4 @@
import * as React from 'react';
import { __ } from '@wordpress/i18n';
import { BlockEditProps } from '@wordpress/blocks';
import {
@@ -9,19 +8,25 @@ import {
PanelBody,
PanelRow,
ExternalLink,
Button,
} from '@wordpress/components';
import { edit } from '@wordpress/icons';
import { edit, external } from '@wordpress/icons';
import { useState } from '@wordpress/element';
import { BlockControls, InspectorControls } from '@wordpress/block-editor';
import { ReactComponent as CogIcon } from '@/assets/cogicon.svg';
import { IBlockAttributes, EmbedMode, IForm } from '@/types';
import { baseUrl } from './globals';
import { ReactComponent as CogIcon } from '@/../cogicon.svg';
import SelectDialog from '@/components/select-dialog';
import PreviewForm from '@/components/preview-form';
import { BlockAttributes, EmbedMode } from '@/types';
const Edit: React.FC<BlockEditProps<BlockAttributes>> = ( { attributes, setAttributes, className } ) => {
const handleForm = ( form: { [key: string]: any } ) => {
const Edit: React.FC<BlockEditProps<IBlockAttributes>> = ( { attributes, setAttributes, className } ) => {
const [ selectDialogOpen, setSelectDialogOpen ] = useState( false );
const handleForm = ( form: IForm ) => {
setAttributes( {
orgId: form.orgId,
formId: form.formId,
seamlessEmbedCode: form.embedCodes.Seamless,
iframeEmbedCode: form.embedCodes.IFrame,
@@ -30,71 +35,81 @@ const Edit: React.FC<BlockEditProps<BlockAttributes>> = ( { attributes, setAttri
} );
};
const resetForm = () => {
// Create a new object which sets all attributes to null
const nullAttributes = Object.keys( attributes ).reduce(
( accumulator, current ) => {
// @ts-ignore
accumulator[ current ] = null;
return accumulator;
}, {} );
setAttributes( nullAttributes );
};
if ( ! attributes.formId ) {
return (
<div>
<Placeholder
icon={ CogIcon }
label="Cognito Forms"
className={ className }
instructions={ __(
'Click the button below to choose a form to embed.'
) }
>
<SelectDialog onSelectForm={ handleForm }></SelectDialog>
</Placeholder>
</div>
);
}
return (
<div>
{
<BlockControls>
<ToolbarButton
icon={ edit }
label="Edit"
onClick={ () => resetForm() }
<div className={ className }>
{ attributes.formId ?
// A form has already been selected, so render the form preview.
<div>
<BlockControls>
<ToolbarButton
icon={ edit }
label="Edit"
onClick={ () => setSelectDialogOpen( true ) }
/>
</BlockControls>
<InspectorControls key="setting">
<PanelBody title="Form Settings">
<PanelRow>
<RadioControl
label="Embed Mode"
help={
<span>
The type of embed code to use with your form. <ExternalLink href="https://www.cognitoforms.com/support/10/style-publish">Learn more</ExternalLink>
</span>
}
selected={ attributes.embedMode }
options={ [
{ label: 'Seamless', value: EmbedMode.Seamless },
{ label: 'Iframe', value: EmbedMode.IFrame },
] }
onChange={ ( value: EmbedMode ) => setAttributes( { embedMode: parseInt( value.toString() ) } ) }
/>
</PanelRow>
</PanelBody>
</InspectorControls>
<PreviewForm
embedCode={ attributes.iframeEmbedCode }
/>
</BlockControls>
</div>
:
// No form has been selected yet, so render the placeholder.
<div>
<Placeholder
icon={ CogIcon }
label="Cognito Forms"
instructions="Choose an existing form to embed or create a new one."
>
<div style={ { display: 'flex' } }>
<Button
variant="primary"
onClick={ () => setSelectDialogOpen( true ) }
>
Select Form
</Button>
<Button
href={ `${ baseUrl }/forms/new` }
target="_blank"
icon={ external }
iconPosition="right"
iconSize={ 16 }
variant="secondary"
>
New Form
</Button>
</div>
</Placeholder>
</div>
}
<InspectorControls key="setting">
<PanelBody title="Embed Settings">
<PanelRow>
<RadioControl
label="Embed Mode"
help={
<span>
The type of embed code to use with your form. <ExternalLink href="https://www.cognitoforms.com/support/10/style-publish">Learn more</ExternalLink>
</span>
}
selected={ attributes.embedMode }
options={ [
{ label: 'Seamless', value: EmbedMode.Seamless },
{ label: 'Iframe', value: EmbedMode.IFrame },
] }
onChange={ ( value: EmbedMode ) => setAttributes( { embedMode: parseInt( value.toString() ) } ) }
/>
</PanelRow>
</PanelBody>
</InspectorControls>
<PreviewForm
embedCode={ attributes.iframeEmbedCode }
/>
{ selectDialogOpen &&
// Selectively render the select dialog
<SelectDialog
setOpen={ ( val: boolean ) => setSelectDialogOpen( val ) }
onSelectForm={ handleForm }
></SelectDialog>
}
</div>
);
};

View File

@@ -1 +1,9 @@
export const baseUrl: string = '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 };

View File

@@ -3,18 +3,23 @@
*/
import { registerBlockType } from '@wordpress/blocks';
import { BlockAttributes } from './types';
import { IBlockAttributes } from './types';
/**
* Internal dependencies
*/
* Internal dependencies
*/
import Edit from './edit';
import Save from './save';
import { ReactComponent as CogIcon } from './assets/cogicon.svg';
/**
* Stylesheets
*/
import './styles/editor.scss';
import './styles/style.scss';
registerBlockType<BlockAttributes>( 'cognito-forms/cognito-embed', {
import { ReactComponent as CogIcon } from '@/../cogicon.svg';
registerBlockType<IBlockAttributes>( 'cognito-forms/cognito-embed', {
title: 'Cognito Forms',
icon: CogIcon,
description: 'Easily build powerful forms.',
@@ -24,6 +29,9 @@ registerBlockType<BlockAttributes>( 'cognito-forms/cognito-embed', {
html: false,
},
attributes: {
orgId: {
type: 'string',
},
formId: {
type: 'string',
},

View File

@@ -2,9 +2,9 @@ import * as React from 'react';
import { BlockSaveProps } from '@wordpress/blocks';
import { EmbedMode, BlockAttributes } from './types';
import { EmbedMode, IBlockAttributes } from './types';
const Save: React.FC<BlockSaveProps<BlockAttributes>> = ( { attributes: { formId, embedMode, seamlessEmbedCode, iframeEmbedCode } } ) => {
const Save: React.FC<BlockSaveProps<IBlockAttributes>> = ( { attributes: { formId, embedMode, seamlessEmbedCode, iframeEmbedCode } } ) => {
let embedCode = '';
switch ( embedMode ) {

View File

@@ -6,52 +6,63 @@
*
*/
// Remove modal padding
.cognito-modal > .components-modal__content {
padding: initial;
}
.cognito-modal > .components-modal__content > .components-modal__header {
margin: initial;
}
// .cog-wp-embed__preview > iframe {
// height: 500px;
// }
.form-preview {
min-height: 200px;
.focus-grabber {
position: absolute;
width: 100%;
height: 100%;
z-index: 1;
.wp-block-cognito-forms-cognito-embed {
.components-placeholder__label svg {
height: 24px;
width: 24px;
}
.loader {
padding: 1em;
background: #fff;
text-align: center;
.form-preview {
min-height: 200px;
border-radius: 2px;
box-shadow: inset 0 0 0 1px #1e1e1e;
display: flex;
gap: 0.5em;
flex-direction: column;
align-items: center;
justify-content: center;
.icon {
width: 2em;
height: 2em;
margin: 0 auto;
.focus-grabber {
position: absolute;
width: 100%;
height: 100%;
z-index: 1;
}
p {
font-size: 13px;
margin: 0;
.loader {
padding: 1em;
background: #fff;
text-align: center;
min-height: 200px;
border-radius: 2px;
box-shadow: inset 0 0 0 1px #1e1e1e;
display: flex;
gap: 0.5em;
flex-direction: column;
align-items: center;
justify-content: center;
.icon {
width: 2em;
height: 2em;
margin: 0 auto;
}
p {
font-size: 13px;
margin: 0;
}
}
}
}
// Remove modal padding
.cognito-modal {
height: 600px;
.components-modal__content {
padding: initial;
}
.components-modal__content::before {
display: none;
}
.components-modal__content .components-modal__header {
margin: initial;
}
}

View File

@@ -1,12 +1,23 @@
export enum EmbedMode {
Seamless,
IFrame
IFrame,
}
export interface BlockAttributes {
formId: string,
export interface IBlockAttributes {
orgId: string;
formId: string;
iframeEmbedCode: string;
seamlessEmbedCode: string;
ampEmbedCode: string;
embedMode: EmbedMode;
}
export interface IForm {
orgId: string;
formId: string;
embedCodes: {
Seamless: string;
IFrame: string;
Amp: string;
}
}

View File

@@ -1,53 +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
*/
$url = 'https://www.cognitoforms.com/';
if ($_GET['page'] == 'CognitoCreateForm') {
$url = $url . 'forms/new';
} elseif ($_GET['page'] == "CognitoTemplates") {
$url = $url . 'templates';
} else {
$url = $url . 'forms';
}
?>
<iframe id="cognito-frame" src="<?= $url ?>"></iframe>
<style>
body {
overflow: hidden;
}
#wpcontent {
padding-left: 0!important;
}
#wpfooter {
display: none;
}
#wpwrap, #wpcontent, #wpbody, #wpbody-content {
height: 100%;
}
#wpbody-content *:not(#cognito-frame) {
display: none!important;
}
#cognito-frame {
width: 100%;
height: 100%;
overflow-x: hidden;
}
</style>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.0 KiB

After

Width:  |  Height:  |  Size: 5.6 KiB

View File

@@ -17,6 +17,8 @@
*/
?>
<?php require_once dirname( __FILE__ ) . '/../api.php'; ?>
<!DOCTYPE html>
<html lang="en">
<head>
@@ -29,6 +31,7 @@
margin: 0;
padding: 0;
height: 100%;
line-height: 0;
}
#cognito-frame {
width: 100%;
@@ -38,7 +41,7 @@
</style>
</head>
<body>
<iframe id="cognito-frame" src="https://forms.cognito.test/integrations/cms"></iframe>
<iframe id="cognito-frame" src="<?= CognitoAPI::$formsBase ?>/integrations/cms"></iframe>
<script type="text/javascript">
window.addEventListener('message', handleMessage);
@@ -48,7 +51,6 @@
var baseUrl = new URL(frame.getAttribute('src')).origin;
if (event.origin === baseUrl) {
console.log('Message received!');
sendData(event.data);
}
}

View File

@@ -13,7 +13,7 @@
editor.addCommand( 'cognito_embed_window', function() {
editor.windowManager.open( {
title: 'Cognito Forms',
url: url + '/dialog.php',
url: ajaxurl + '?action=cognito_tinymce_dialog',
width: 500,
height: 500,
} );

2279
yarn.lock

File diff suppressed because it is too large Load Diff