| 1 |
<?php |
| 2 |
/** |
| 3 |
*@package formfacade |
| 4 |
**/ |
| 5 |
/** |
| 6 |
* Plugin Name: FormFacade |
| 7 |
* Plugin URI: https://formfacade.com/website/how-to-embed-google-forms-in-wordpress.html |
| 8 |
* Description: Customize your Google Form to suit your wordpress site |
| 9 |
* Version: 1.2.8 |
| 10 |
* Author: FormFacade |
| 11 |
* Author URI: https://formfacade.com |
| 12 |
* License: GPL v2 or Later |
| 13 |
* Text Domain: formfacade |
| 14 |
*/ |
| 15 |
/* |
| 16 |
This program is free software; you can redistribute it and/or |
| 17 |
modify it under the terms of the GNU General Public License |
| 18 |
as published by the Free Software Foundation; either version 2 |
| 19 |
of the License, or (at your option) any later version. |
| 20 |
|
| 21 |
This program is distributed in the hope that it will be useful, |
| 22 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 23 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 24 |
GNU General Public License for more details. |
| 25 |
|
| 26 |
You should have received a copy of the GNU General Public License |
| 27 |
along with this program; if not, write to the Free Software |
| 28 |
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
| 29 |
|
| 30 |
Copyright 2019 Mailrecipe LLC. |
| 31 |
*/ |
| 32 |
|
| 33 |
defined('ABSPATH') or die('Sorry! This request is not called properly'); |
| 34 |
|
| 35 |
function_exists('add_action') or die('Sorry! This request is called outside wordpress'); |
| 36 |
|
| 37 |
class FormFacade |
| 38 |
{ |
| 39 |
function activate() |
| 40 |
{ |
| 41 |
} |
| 42 |
|
| 43 |
function deactivate() |
| 44 |
{ |
| 45 |
echo 'FormFacade plugin deactivated'; |
| 46 |
} |
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
function renderFacade($atts = []) |
| 51 |
{ |
| 52 |
$id = sanitize_text_field($atts['id']); |
| 53 |
$appearance = 'wordpress'; |
| 54 |
|
| 55 |
// Check for appearance attributes |
| 56 |
if (array_key_exists('appearance', $atts)) { |
| 57 |
$appearance = sanitize_text_field($atts['appearance']); |
| 58 |
} |
| 59 |
|
| 60 |
// Check for owner attributes |
| 61 |
if (array_key_exists('owner', $atts)) { |
| 62 |
$owner = sanitize_text_field($atts['owner']); |
| 63 |
return '<div id="ff-' . esc_attr($id) . '"></div><script async defer src="https://formfacade.com/include/' . esc_attr($owner) . '/form/' . esc_attr($id) . '/' . esc_attr($appearance) . '.js?div=ff-' . esc_attr($id) . '"></script>'; |
| 64 |
} else if ($id) { |
| 65 |
return '<div id="ff-' . esc_attr($id) . '"></div><script async defer src="https://formfacade.com/forms/d/e/' . esc_attr($id) . '/' . esc_attr($appearance) . '.js?div=ff-' . esc_attr($id) . '"></script>'; |
| 66 |
} else { |
| 67 |
return '<div>Invalid form id.<br/>- For example, if the public url of your Google Form is: https://docs.google.com/forms/d/e/<span style="background:yellow;color:red;">1FAIpQLSdN-M-uIQN8FfjAZul_BQi0MKYARV_vqNKFejV0QFomAjtdGg</span>/viewform<br/>- Your public id is: 1FAIpQLSdN-M-uIQN8FfjAZul_BQi0MKYARV_vqNKFejV0QFomAjtdGg<br/>- So, the short code that you need to add to your page will be: <br/>[formfacade id=1FAIpQLSdN-M-uIQN8FfjAZul_BQi0MKYARV_vqNKFejV0QFomAjtdGg]<br/><br/><i>For Support Contact: <b>support@formfacade.com</b></i></div>'; |
| 68 |
} |
| 69 |
} |
| 70 |
} |
| 71 |
|
| 72 |
$formfacade = new FormFacade(); |
| 73 |
|
| 74 |
|
| 75 |
register_activation_hook( __FILE__, array($formfacade, 'activate')); |
| 76 |
register_deactivation_hook( __FILE__, array($formfacade, 'deactivate')); |
| 77 |
add_shortcode('formfacade', array($formfacade, 'renderFacade')); |
| 78 |
|