Version Description
No known upgrade issues.
Download this release
Release Info
Developer | mpwalsh8 |
Plugin | Google Forms |
Version | 0.39 |
Comparing to | |
See all releases |
Code changes from version 0.38 to 0.39
- index.php +2 -2
- readme.txt +10 -4
- wpgform-core.php +60 -17
index.php
CHANGED
@@ -4,8 +4,8 @@
|
|
4 |
* Plugin Name: WordPress Google Form
|
5 |
* Plugin URI: http://michaelwalsh.org/wordpress/wordpress-plugins/wpgform/
|
6 |
* Description: Add Google Forms to a WordPress web site. Display a Google Form directly into your posts, pages or sidebar. Style the Google Form to match your existing theme and display a custom confirmation page after form submission.
|
7 |
-
* Version: 0.
|
8 |
-
* Build: 0.
|
9 |
* Last Modified: $WCDATE$
|
10 |
* Author: Mike Walsh
|
11 |
* Author URI: http://www.michaelwalsh.org
|
4 |
* Plugin Name: WordPress Google Form
|
5 |
* Plugin URI: http://michaelwalsh.org/wordpress/wordpress-plugins/wpgform/
|
6 |
* Description: Add Google Forms to a WordPress web site. Display a Google Form directly into your posts, pages or sidebar. Style the Google Form to match your existing theme and display a custom confirmation page after form submission.
|
7 |
+
* Version: 0.39
|
8 |
+
* Build: 0.39.$WCREV$
|
9 |
* Last Modified: $WCDATE$
|
10 |
* Author: Mike Walsh
|
11 |
* Author URI: http://www.michaelwalsh.org
|
readme.txt
CHANGED
@@ -3,8 +3,8 @@ Contributors: mpwalsh8
|
|
3 |
Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=DK4MS3AA983CC
|
4 |
Tags: Google Forms, Google Docs, Google, Spreadsheet, shortcode, forms
|
5 |
Requires at least: 3.0
|
6 |
-
Tested up to: 3.4.
|
7 |
-
Stable tag: 0.
|
8 |
|
9 |
Embeds a published, public Google Form in a WordPress post, page, or widget.
|
10 |
|
@@ -31,7 +31,9 @@ Currently, this plugin only supports Google Forms that are "Published as a web p
|
|
31 |
|
32 |
The WordPress Google Form shortcode `gform` supports a number of attributes that allow further control and customization of the Google Form.
|
33 |
|
34 |
-
`[gform form='<full_url_to_Google_Form>' confirm='<full_url_to_confirmation_page>' class='<value>' legal='on|off' br='on|off' prefix='<value>' suffix='<value>' email='on|off' style='redirect|ajax']`
|
|
|
|
|
35 |
|
36 |
* __form__: The full URL to the published Google Form. You must be able to open this URL successfully from a browser for the __gform__ shortcode to work properly.
|
37 |
* __confirm__: A full URL to the confirmation (e.g. _Thanks for your submission!_) page. Be default Google displays a very basic confirmation page which cannot be integrated easily with your WordPress site. The _confirm_ attribute allows the form submission to land on a page of your choosing. **It is strongly encouraged that you make use of a confirmation page.** It will make the form submission process cleaner and clearer to the end user. The confirmation page will be displayed by a page redirect unless a different behavior is specified using the __style__ attribute.
|
@@ -47,8 +49,9 @@ The WordPress Google Form shortcode `gform` supports a number of attributes that
|
|
47 |
* __email__: Notify the site's WordPress administrator (or sendto email address) that a form has been submitted by setting the __email__ attribute to __on__. This will result in an email being sent to the blog administrator (or sendto email address) letting them know a form was submitted with the URL of the form along with the date and time of submission.
|
48 |
* __sendto__: Notify the "sendto" email address that a form has been submitted by setting the __email__ attribute to __on__. This will result in an email being sent to the "sendto" letting them know a form was submitted with the URL of the form along with the date and time of submission. The email message will always be sent to the blog administrator via Bcc.
|
49 |
* __spreadsheet__: The full URL to the "Shared" Google Docs Spreadsheet which stores the form responses. You must be able to open this URL successfully from a browser for the link in the email to work properly. This attribute is used in conjunction with the __email__ attribute, it has no effect when the __email__ attribute is not turned __on__.
|
|
|
50 |
|
51 |
-
`[gform form='https://docs.google.com/spreadsheet/viewform?hl=en_US&pli=1&formkey=ABCDEFGHIJKLMNOPQRSTUVWXYZ12345678#gid=0' confirm='http://www.example.com/thankyou/' style='ajax' class='mygform' legal='off' prefix='mygform-' br='on' title='on' maph1h2='on' email='on']`
|
52 |
|
53 |
== Frequently Asked Questions ==
|
54 |
|
@@ -193,6 +196,9 @@ No known upgrade issues.
|
|
193 |
|
194 |
== Changelog ==
|
195 |
|
|
|
|
|
|
|
196 |
= Version 0.38 =
|
197 |
* Removed debug code left in from working on problem fixed in v0.36.
|
198 |
|
3 |
Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=DK4MS3AA983CC
|
4 |
Tags: Google Forms, Google Docs, Google, Spreadsheet, shortcode, forms
|
5 |
Requires at least: 3.0
|
6 |
+
Tested up to: 3.4.2
|
7 |
+
Stable tag: 0.39
|
8 |
|
9 |
Embeds a published, public Google Form in a WordPress post, page, or widget.
|
10 |
|
31 |
|
32 |
The WordPress Google Form shortcode `gform` supports a number of attributes that allow further control and customization of the Google Form.
|
33 |
|
34 |
+
`[gform form='<full_url_to_Google_Form>' confirm='<full_url_to_confirmation_page>' class='<value>' legal='on|off' br='on|off' prefix='<value>' suffix='<value>' email='on|off' sendto='<email address>' style='redirect|ajax' spreadsheet='<full_url_to_Google_Spreadsheet>' unitethemehack='on|off']`
|
35 |
+
|
36 |
+
*NOTE:* In the above syntax, values enclosed in angle brackets <>, indicate a string you need to replace with an appropriate value. Do not include the angle brackets in your string!
|
37 |
|
38 |
* __form__: The full URL to the published Google Form. You must be able to open this URL successfully from a browser for the __gform__ shortcode to work properly.
|
39 |
* __confirm__: A full URL to the confirmation (e.g. _Thanks for your submission!_) page. Be default Google displays a very basic confirmation page which cannot be integrated easily with your WordPress site. The _confirm_ attribute allows the form submission to land on a page of your choosing. **It is strongly encouraged that you make use of a confirmation page.** It will make the form submission process cleaner and clearer to the end user. The confirmation page will be displayed by a page redirect unless a different behavior is specified using the __style__ attribute.
|
49 |
* __email__: Notify the site's WordPress administrator (or sendto email address) that a form has been submitted by setting the __email__ attribute to __on__. This will result in an email being sent to the blog administrator (or sendto email address) letting them know a form was submitted with the URL of the form along with the date and time of submission.
|
50 |
* __sendto__: Notify the "sendto" email address that a form has been submitted by setting the __email__ attribute to __on__. This will result in an email being sent to the "sendto" letting them know a form was submitted with the URL of the form along with the date and time of submission. The email message will always be sent to the blog administrator via Bcc.
|
51 |
* __spreadsheet__: The full URL to the "Shared" Google Docs Spreadsheet which stores the form responses. You must be able to open this URL successfully from a browser for the link in the email to work properly. This attribute is used in conjunction with the __email__ attribute, it has no effect when the __email__ attribute is not turned __on__.
|
52 |
+
* __unitethemehack__: Off by default, this attribute should be enabled, `unitethemehack='on'`, when using the [Unite theme from Paralleus](http://themeforest.net/item/unite-wordpress-business-magazine-theme/90959). The Unite theme manipulates the submit button(s) on a page, the result of which is a button that prevents the Google form from being submitted. Turning this attribute on enables a hack which inserts *class="noStyle"* to all submit buttons, preventing Unite from mucking with them.
|
53 |
|
54 |
+
`[gform form='https://docs.google.com/spreadsheet/viewform?hl=en_US&pli=1&formkey=ABCDEFGHIJKLMNOPQRSTUVWXYZ12345678#gid=0' confirm='http://www.example.com/thankyou/' style='ajax' class='mygform' legal='off' prefix='mygform-' br='on' title='on' maph1h2='on' email='on' spreadsheet='https://docs.google.com/spreadsheet/ccc?key=0AgBHWDGsX0PUdE56R1ZldXo4a0N3VTNMNEpSemdGV3c' unitethemehack='off']`
|
55 |
|
56 |
== Frequently Asked Questions ==
|
57 |
|
196 |
|
197 |
== Changelog ==
|
198 |
|
199 |
+
= Version 0.39 =
|
200 |
+
* Added new attribute *unitedthemehack='on|off', which defaults to 'off'. This attribute allows WordPress Google Form to work correctly with Paralleus' Unite theme (which mucks with the submit button(s) on the Google Form preventing the form from being submitted).
|
201 |
+
|
202 |
= Version 0.38 =
|
203 |
* Removed debug code left in from working on problem fixed in v0.36.
|
204 |
|
wpgform-core.php
CHANGED
@@ -226,6 +226,8 @@ class wpGForm
|
|
226 |
$form = $options['form'] ;
|
227 |
}
|
228 |
|
|
|
|
|
229 |
// Custom Alert Message? Optional
|
230 |
if (!$options['alert'])
|
231 |
{
|
@@ -314,6 +316,13 @@ class wpGForm
|
|
314 |
$sendto = is_email($options['sendto']) ;
|
315 |
}
|
316 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
317 |
|
318 |
// Show the custom confirmation via AJAX instead of redirect?
|
319 |
$style = $options['style'] ;
|
@@ -342,6 +351,8 @@ class wpGForm
|
|
342 |
else
|
343 |
$html = self::$response['body'] ;
|
344 |
|
|
|
|
|
345 |
// Need to filter the HTML retrieved from the form and strip off the stuff
|
346 |
// we don't want. This gets rid of the HTML wrapper from the Google page.
|
347 |
|
@@ -398,6 +409,8 @@ class wpGForm
|
|
398 |
return '<div class="gform-google-error">Unexpected content encountered, unable to retrieve Google Form.</div>' ;
|
399 |
}
|
400 |
|
|
|
|
|
401 |
// Strip off anything prior to the first DIV, we don't want it.
|
402 |
|
403 |
if ($first_div !== 0)
|
@@ -470,6 +483,15 @@ class wpGForm
|
|
470 |
$action = null ;
|
471 |
}
|
472 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
473 |
// Encode all of the short code options so they can
|
474 |
// be referenced if/when needed during form processing.
|
475 |
|
@@ -561,7 +583,7 @@ jQuery(document).ready(function($) {
|
|
561 |
' ;
|
562 |
|
563 |
// Tidy up Javascript to ensure it isn't affected by 'the_content' filters
|
564 |
-
|
565 |
|
566 |
// Send email?
|
567 |
if (self::$posted && is_null($action) && $email)
|
@@ -614,6 +636,8 @@ jQuery(document).ready(function($) {
|
|
614 |
if (WPGFORM_DEBUG) wpgform_preprint_r($_POST) ;
|
615 |
if (!empty($_POST) && array_key_exists('gform-action', $_POST))
|
616 |
{
|
|
|
|
|
617 |
self::$posted = true ;
|
618 |
|
619 |
$wpgform_options = wpgform_get_plugin_options() ;
|
@@ -643,7 +667,7 @@ jQuery(document).ready(function($) {
|
|
643 |
}
|
644 |
//print_r($_POST) ;
|
645 |
*/
|
646 |
-
if (WPGFORM_DEBUG) wpgform_whereami(__FILE__, __LINE__) ;
|
647 |
if (WPGFORM_DEBUG) wpgform_preprint_r($_POST) ;
|
648 |
|
649 |
$action = unserialize(base64_decode($_POST['gform-action'])) ;
|
@@ -663,35 +687,53 @@ jQuery(document).ready(function($) {
|
|
663 |
$patterns = array('/^entry_([0-9]+)_(single|group)_/', '/^entry_([0-9]+)_/') ;
|
664 |
$replacements = array('entry.\1.\2.', 'entry.\1.') ;
|
665 |
|
|
|
|
|
|
|
666 |
foreach ($_POST as $key => $value)
|
667 |
{
|
|
|
|
|
|
|
668 |
// Need to handle parameters passed as array values
|
669 |
// separately because of how Python (used Google)
|
670 |
// handles array arguments differently than PHP does.
|
671 |
|
672 |
if (is_array($_POST[$key]))
|
673 |
{
|
|
|
674 |
$pa = &$_POST[$key] ;
|
675 |
foreach ($pa as $pv)
|
676 |
$body .= preg_replace($patterns, $replacements, $key) . '=' . rawurlencode($pv) . '&' ;
|
677 |
}
|
678 |
else
|
679 |
{
|
|
|
680 |
$body .= preg_replace($patterns, $replacements, $key) . '=' . rawurlencode($value) . '&' ;
|
681 |
}
|
682 |
}
|
683 |
|
684 |
//$form = str_replace($action, 'action="' . get_permalink(get_the_ID()) . '"', $form) ;
|
685 |
$form = str_replace($action, 'action=""', $form) ;
|
|
|
|
|
686 |
|
687 |
// WordPress converts all of the ampersand characters to their
|
688 |
// appropriate HTML entity or some variety of it. Need to undo
|
689 |
// that so the URL can be actually be used.
|
690 |
|
691 |
$action = str_replace(array('&','&','&'), '&', $action) ;
|
|
|
|
|
|
|
|
|
|
|
692 |
|
693 |
self::$response = wp_remote_post($action,
|
694 |
array('sslverify' => false, 'body' => $body)) ;
|
|
|
|
|
|
|
695 |
}
|
696 |
else
|
697 |
{
|
@@ -729,21 +771,22 @@ jQuery(document).ready(function($) {
|
|
729 |
*/
|
730 |
function RenderGForm($atts) {
|
731 |
$params = shortcode_atts(array(
|
732 |
-
'form'
|
733 |
-
'confirm'
|
734 |
-
'alert'
|
735 |
-
'class'
|
736 |
-
'legal'
|
737 |
-
'br'
|
738 |
-
'suffix'
|
739 |
-
'prefix'
|
740 |
-
'readonly'
|
741 |
-
'title'
|
742 |
-
'maph1h2'
|
743 |
-
'email'
|
744 |
-
'sendto'
|
745 |
-
'spreadsheet'
|
746 |
-
'
|
|
|
747 |
), $atts) ;
|
748 |
|
749 |
return wpGForm::ConstructGForm($params) ;
|
226 |
$form = $options['form'] ;
|
227 |
}
|
228 |
|
229 |
+
if (WPGFORM_DEBUG) wpgform_whereami(__FILE__, __LINE__, 'ConstructGForm') ;
|
230 |
+
|
231 |
// Custom Alert Message? Optional
|
232 |
if (!$options['alert'])
|
233 |
{
|
316 |
$sendto = is_email($options['sendto']) ;
|
317 |
}
|
318 |
|
319 |
+
// The Unite theme from Paralleus mucks with the submit buttons
|
320 |
+
// which breaks the ability to submit the form to Google correctly.
|
321 |
+
// This hack will "unbreak" the submit buttons.
|
322 |
+
|
323 |
+
$unitethemehack = $options['unitethemehack'] === 'on' ;
|
324 |
+
|
325 |
+
if (WPGFORM_DEBUG) wpgform_whereami(__FILE__, __LINE__, 'ConstructGForm') ;
|
326 |
|
327 |
// Show the custom confirmation via AJAX instead of redirect?
|
328 |
$style = $options['style'] ;
|
351 |
else
|
352 |
$html = self::$response['body'] ;
|
353 |
|
354 |
+
if (WPGFORM_DEBUG) wpgform_whereami(__FILE__, __LINE__, 'ConstructGForm') ;
|
355 |
+
|
356 |
// Need to filter the HTML retrieved from the form and strip off the stuff
|
357 |
// we don't want. This gets rid of the HTML wrapper from the Google page.
|
358 |
|
409 |
return '<div class="gform-google-error">Unexpected content encountered, unable to retrieve Google Form.</div>' ;
|
410 |
}
|
411 |
|
412 |
+
if (WPGFORM_DEBUG) wpgform_whereami(__FILE__, __LINE__, 'ConstructGForm') ;
|
413 |
+
|
414 |
// Strip off anything prior to the first DIV, we don't want it.
|
415 |
|
416 |
if ($first_div !== 0)
|
483 |
$action = null ;
|
484 |
}
|
485 |
|
486 |
+
// The Unite theme from Paralleus mucks with the submit buttons
|
487 |
+
// which breaks the ability to submit the form to Google correctly.
|
488 |
+
// This hack will "unbreak" the submit buttons.
|
489 |
+
|
490 |
+
if ($unitethemehack)
|
491 |
+
$html = preg_replace('/<input type="submit"/i', '<input class="noStyle" type="submit"', $html) ;
|
492 |
+
|
493 |
+
if (WPGFORM_DEBUG) wpgform_whereami(__FILE__, __LINE__, 'ConstructGForm') ;
|
494 |
+
|
495 |
// Encode all of the short code options so they can
|
496 |
// be referenced if/when needed during form processing.
|
497 |
|
583 |
' ;
|
584 |
|
585 |
// Tidy up Javascript to ensure it isn't affected by 'the_content' filters
|
586 |
+
$js = preg_replace($patterns, $replacements, $js) . PHP_EOL ;
|
587 |
|
588 |
// Send email?
|
589 |
if (self::$posted && is_null($action) && $email)
|
636 |
if (WPGFORM_DEBUG) wpgform_preprint_r($_POST) ;
|
637 |
if (!empty($_POST) && array_key_exists('gform-action', $_POST))
|
638 |
{
|
639 |
+
if (WPGFORM_DEBUG) wpgform_whereami(__FILE__, __LINE__, 'ProcessGForm') ;
|
640 |
+
|
641 |
self::$posted = true ;
|
642 |
|
643 |
$wpgform_options = wpgform_get_plugin_options() ;
|
667 |
}
|
668 |
//print_r($_POST) ;
|
669 |
*/
|
670 |
+
if (WPGFORM_DEBUG) wpgform_whereami(__FILE__, __LINE__, 'ProcessGForm') ;
|
671 |
if (WPGFORM_DEBUG) wpgform_preprint_r($_POST) ;
|
672 |
|
673 |
$action = unserialize(base64_decode($_POST['gform-action'])) ;
|
687 |
$patterns = array('/^entry_([0-9]+)_(single|group)_/', '/^entry_([0-9]+)_/') ;
|
688 |
$replacements = array('entry.\1.\2.', 'entry.\1.') ;
|
689 |
|
690 |
+
if (WPGFORM_DEBUG) wpgform_whereami(__FILE__, __LINE__, 'ProcessGForm') ;
|
691 |
+
if (WPGFORM_DEBUG) wpgform_preprint_r($_POST) ;
|
692 |
+
|
693 |
foreach ($_POST as $key => $value)
|
694 |
{
|
695 |
+
if (WPGFORM_DEBUG) wpgform_whereami(__FILE__, __LINE__, 'ProcessGForm') ;
|
696 |
+
if (WPGFORM_DEBUG) wpgform_preprint_r($key, $value) ;
|
697 |
+
|
698 |
// Need to handle parameters passed as array values
|
699 |
// separately because of how Python (used Google)
|
700 |
// handles array arguments differently than PHP does.
|
701 |
|
702 |
if (is_array($_POST[$key]))
|
703 |
{
|
704 |
+
if (WPGFORM_DEBUG) wpgform_whereami(__FILE__, __LINE__, 'ProcessGForm') ;
|
705 |
$pa = &$_POST[$key] ;
|
706 |
foreach ($pa as $pv)
|
707 |
$body .= preg_replace($patterns, $replacements, $key) . '=' . rawurlencode($pv) . '&' ;
|
708 |
}
|
709 |
else
|
710 |
{
|
711 |
+
if (WPGFORM_DEBUG) wpgform_whereami(__FILE__, __LINE__, 'ProcessGForm') ;
|
712 |
$body .= preg_replace($patterns, $replacements, $key) . '=' . rawurlencode($value) . '&' ;
|
713 |
}
|
714 |
}
|
715 |
|
716 |
//$form = str_replace($action, 'action="' . get_permalink(get_the_ID()) . '"', $form) ;
|
717 |
$form = str_replace($action, 'action=""', $form) ;
|
718 |
+
var_dump($form) ;
|
719 |
+
|
720 |
|
721 |
// WordPress converts all of the ampersand characters to their
|
722 |
// appropriate HTML entity or some variety of it. Need to undo
|
723 |
// that so the URL can be actually be used.
|
724 |
|
725 |
$action = str_replace(array('&','&','&'), '&', $action) ;
|
726 |
+
if (WPGFORM_DEBUG)
|
727 |
+
{
|
728 |
+
wpgform_preprint_r($action) ;
|
729 |
+
wpgform_preprint_r($body) ;
|
730 |
+
}
|
731 |
|
732 |
self::$response = wp_remote_post($action,
|
733 |
array('sslverify' => false, 'body' => $body)) ;
|
734 |
+
|
735 |
+
if (WPGFORM_DEBUG) wpgform_whereami(__FILE__, __LINE__, 'ProcessGForm') ;
|
736 |
+
if (WPGFORM_DEBUG) wpgform_preprint_r(self::$response) ;
|
737 |
}
|
738 |
else
|
739 |
{
|
771 |
*/
|
772 |
function RenderGForm($atts) {
|
773 |
$params = shortcode_atts(array(
|
774 |
+
'form' => false, // Google Form URL
|
775 |
+
'confirm' => false, // Custom confirmation page URL to redirect to
|
776 |
+
'alert' => null, // Optional Alert Message
|
777 |
+
'class' => 'gform', // Container element's custom class value
|
778 |
+
'legal' => 'on', // Display Google Legal Stuff
|
779 |
+
'br' => 'off', // Insert <br> tags between labels and inputs
|
780 |
+
'suffix' => null, // Add suffix character(s) to all labels
|
781 |
+
'prefix' => null, // Add suffix character(s) to all labels
|
782 |
+
'readonly' => 'off', // Set all form elements to disabled
|
783 |
+
'title' => 'on', // Remove the H1 element(s) from the Form
|
784 |
+
'maph1h2' => 'off', // Map H1 element(s) on the form to H2 element(s)
|
785 |
+
'email' => 'off', // Send an email confirmation to blog admin on submission
|
786 |
+
'sendto' => null, // Send an email confirmation to a specific address on submission
|
787 |
+
'spreadsheet' => false, // Google Spreadsheet URL
|
788 |
+
'unitethemehack' => 'off', // Send an email confirmation to blog admin on submission
|
789 |
+
'style' => WPGFORM_CONFIRM_REDIRECT // How to present the custom confirmation after submit
|
790 |
), $atts) ;
|
791 |
|
792 |
return wpGForm::ConstructGForm($params) ;
|