Version Description
No known upgrade issues.
Download this release
Release Info
Developer | mpwalsh8 |
Plugin | Google Forms |
Version | 0.30 |
Comparing to | |
See all releases |
Code changes from version 0.28 to 0.30
- index.php +2 -2
- readme.txt +10 -2
- wpgform-core.php +41 -13
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.30
|
8 |
+
* Build: 0.30.$WCREV$
|
9 |
* Last Modified: $WCDATE$
|
10 |
* Author: Mike Walsh
|
11 |
* Author URI: http://www.michaelwalsh.org
|
readme.txt
CHANGED
@@ -4,7 +4,7 @@ Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_i
|
|
4 |
Tags: Google Forms, Google Docs, Google, Spreadsheet, shortcode, forms
|
5 |
Requires at least: 3.0
|
6 |
Tested up to: 3.3.1
|
7 |
-
Stable tag: 0.
|
8 |
|
9 |
Embeds a published, public Google Form in a WordPress post, page, or widget.
|
10 |
|
@@ -44,7 +44,8 @@ The WordPress Google Form shortcode `gform` supports a number of attributes that
|
|
44 |
* __suffix__: Append a character string to the end of each form label. This can also be accomplished using CSS, refer to the CSS section.
|
45 |
* __title__: By default Google Forms have title wrapped in a <h1> tag. If you do not want to include this form title as part of the form, add `title='off'` to your shortcode usage. The <h1> content is removed from the form.
|
46 |
* __maph1h2__: By default Google Forms have title wrapped in a <h1> tag. If you want the form title but not as an <h1> element, add `maph1h2='on'` to your shortcode usage. The <h1> elements will be mapped to <h2> elements. The CSS class attributes remain unchanged.
|
47 |
-
* __email__: Notify the site's WordPress administrator 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 letting them know a form was submitted with the URL of the form along with the date and time of submission.
|
|
|
48 |
|
49 |
`[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']`
|
50 |
|
@@ -182,6 +183,13 @@ No known upgrade issues.
|
|
182 |
|
183 |
== Changelog ==
|
184 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
185 |
= Version 0.28 =
|
186 |
* Fixed bug with missing GetPageURL method which appears when email confirmation is enabled (email='on').
|
187 |
|
4 |
Tags: Google Forms, Google Docs, Google, Spreadsheet, shortcode, forms
|
5 |
Requires at least: 3.0
|
6 |
Tested up to: 3.3.1
|
7 |
+
Stable tag: 0.30
|
8 |
|
9 |
Embeds a published, public Google Form in a WordPress post, page, or widget.
|
10 |
|
44 |
* __suffix__: Append a character string to the end of each form label. This can also be accomplished using CSS, refer to the CSS section.
|
45 |
* __title__: By default Google Forms have title wrapped in a <h1> tag. If you do not want to include this form title as part of the form, add `title='off'` to your shortcode usage. The <h1> content is removed from the form.
|
46 |
* __maph1h2__: By default Google Forms have title wrapped in a <h1> tag. If you want the form title but not as an <h1> element, add `maph1h2='on'` to your shortcode usage. The <h1> elements will be mapped to <h2> elements. The CSS class attributes remain unchanged.
|
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 |
|
50 |
`[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']`
|
51 |
|
183 |
|
184 |
== Changelog ==
|
185 |
|
186 |
+
= Version 0.30 =
|
187 |
+
* Changed generated CSS to limit the possibility that it is affected by 'the_content' or 'wpautop' filters resulting in CSS errors. This rare situation would prevent the custom CSS from being applied correctly.
|
188 |
+
|
189 |
+
= Version 0.29 =
|
190 |
+
* Added ability to specify email address when email='on' attribute is in use via new attribute 'sendto'.
|
191 |
+
* Changed generated Javascript to limit the possibility that it is affected by 'the_content' or 'wpautop' filters resulting in Javascript errors. This rare situation would prevent the page confirmation or redirection from loading correctly.
|
192 |
+
|
193 |
= Version 0.28 =
|
194 |
* Fixed bug with missing GetPageURL method which appears when email confirmation is enabled (email='on').
|
195 |
|
wpgform-core.php
CHANGED
@@ -42,6 +42,7 @@ function wpgform_init()
|
|
42 |
add_filter('widget_text', 'do_shortcode') ;
|
43 |
|
44 |
add_action('template_redirect', 'wpgform_head') ;
|
|
|
45 |
}
|
46 |
|
47 |
/**
|
@@ -264,6 +265,17 @@ class wpGForm
|
|
264 |
// Should email confirmation be sent?
|
265 |
$email = $options['email'] === 'on' ;
|
266 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
267 |
// Show the custom confirmation via AJAX instead of redirect?
|
268 |
$style = $options['style'] ;
|
269 |
|
@@ -448,8 +460,8 @@ class wpGForm
|
|
448 |
$action = $matches[0][$i] ;
|
449 |
}
|
450 |
|
451 |
-
|
452 |
-
|
453 |
$action = preg_replace('/^action/i', 'value', $action) ;
|
454 |
|
455 |
$html = preg_replace('/<\/form>/i',
|
@@ -469,12 +481,20 @@ class wpGForm
|
|
469 |
else
|
470 |
$css = '' ;
|
471 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
472 |
// Output Javscript for form validation, make sure any class prefix is included
|
|
|
|
|
|
|
473 |
$js = sprintf('
|
474 |
<script type="text/javascript">
|
475 |
jQuery(document).ready(function($) {
|
476 |
-
// Need to fix the name arguments for checkboxes
|
477 |
-
// so PHP will pass them as an array correctly.
|
478 |
$("div.%sss-form-container input:checkbox").each(function(index) {
|
479 |
this.name = this.name + \'[]\';
|
480 |
});
|
@@ -504,10 +524,14 @@ jQuery(document).ready(function($) {
|
|
504 |
</script>
|
505 |
' ;
|
506 |
|
|
|
|
|
|
|
|
|
507 |
// Send email?
|
508 |
if ($posted && is_null($action) && $email)
|
509 |
{
|
510 |
-
wpGForm::SendConfirmationEmail($wpgform_options['email_format']) ;
|
511 |
}
|
512 |
|
513 |
// Check browser compatibility? The jQuery used by this plugin may
|
@@ -542,6 +566,7 @@ jQuery(document).ready(function($) {
|
|
542 |
*/
|
543 |
function GetPageURL()
|
544 |
{
|
|
|
545 |
$pageURL = 'http' ;
|
546 |
|
547 |
if ($_SERVER["HTTPS"] == "on") $pageURL .= 's' ;
|
@@ -576,6 +601,7 @@ jQuery(document).ready(function($) {
|
|
576 |
'title' => 'on', // Remove the H1 element(s) from the Form
|
577 |
'maph1h2' => 'off', // Map H1 element(s) on the form to H2 element(s)
|
578 |
'email' => 'off', // Send an email confirmation to blog admin on submission
|
|
|
579 |
'style' => WPGFORM_CONFIRM_REDIRECT // How to present the custom confirmation after submit
|
580 |
), $atts) ;
|
581 |
|
@@ -590,8 +616,10 @@ jQuery(document).ready(function($) {
|
|
590 |
*
|
591 |
* @param string $action - action to take, register or unregister
|
592 |
*/
|
593 |
-
function SendConfirmationEmail($mode = WPGFORM_EMAIL_FORMAT_HTML)
|
594 |
{
|
|
|
|
|
595 |
if ($mode == WPGFORM_EMAIL_FORMAT_HTML)
|
596 |
{
|
597 |
$headers = 'MIME-Version: 1.0' . PHP_EOL ;
|
@@ -603,11 +631,11 @@ jQuery(document).ready(function($) {
|
|
603 |
}
|
604 |
|
605 |
$headers .= sprintf("From: %s <%s>",
|
606 |
-
get_bloginfo('name'),
|
607 |
|
608 |
-
$headers .= sprintf("Cc: %s",
|
609 |
$headers .= sprintf("Bcc: %s", get_bloginfo('admin_email')) . PHP_EOL ;
|
610 |
-
$headers .= sprintf("Reply-To: %s",
|
611 |
$headers .= sprintf("X-Mailer: PHP/%s", phpversion()) ;
|
612 |
|
613 |
if ($mode == WPGFORM_EMAIL_FORMAT_HTML)
|
@@ -619,7 +647,7 @@ jQuery(document).ready(function($) {
|
|
619 |
</head>
|
620 |
<body>
|
621 |
<p>
|
622 |
-
|
623 |
</p>
|
624 |
<p>
|
625 |
A form was submitted on your web site.
|
@@ -644,7 +672,7 @@ jQuery(document).ready(function($) {
|
|
644 |
}
|
645 |
else
|
646 |
{
|
647 |
-
$plain = '
|
648 |
$plain .= 'A form was submitted on your web site:' . PHP_EOL . PHP_EOL ;
|
649 |
$plain .= 'URL: %s' . PHP_EOL . 'Date: %s' . PHP_EOL . 'Time: %s' . PHP_EOL . PHP_EOL ;
|
650 |
$plain .= 'Thank you,' . PHP_EOL . PHP_EOL . '%s' . PHP_EOL ;
|
@@ -653,8 +681,8 @@ jQuery(document).ready(function($) {
|
|
653 |
date('Y-m-d'), date('H:i'), get_option('blogname')) ;
|
654 |
}
|
655 |
|
656 |
-
$to = sprintf('%s
|
657 |
-
get_option('blogname'),
|
658 |
get_option('blogname'), get_option('admin_email')) ;
|
659 |
|
660 |
$subject = sprintf('Form Submission from %s', get_option('blogname')) ;
|
42 |
add_filter('widget_text', 'do_shortcode') ;
|
43 |
|
44 |
add_action('template_redirect', 'wpgform_head') ;
|
45 |
+
add_filter('the_content', 'wpautop');
|
46 |
}
|
47 |
|
48 |
/**
|
265 |
// Should email confirmation be sent?
|
266 |
$email = $options['email'] === 'on' ;
|
267 |
|
268 |
+
// Who should email confirmation be sent to?
|
269 |
+
if (!$options['sendto'])
|
270 |
+
{
|
271 |
+
$sendto = null ;
|
272 |
+
}
|
273 |
+
else
|
274 |
+
{
|
275 |
+
$sendto = is_email($options['sendto']) ;
|
276 |
+
}
|
277 |
+
|
278 |
+
|
279 |
// Show the custom confirmation via AJAX instead of redirect?
|
280 |
$style = $options['style'] ;
|
281 |
|
460 |
$action = $matches[0][$i] ;
|
461 |
}
|
462 |
|
463 |
+
$html = str_replace($action, 'action="' . get_permalink(get_the_ID()) . '"', $html) ;
|
464 |
+
//$html = str_replace($action, 'action=""', $html) ;
|
465 |
$action = preg_replace('/^action/i', 'value', $action) ;
|
466 |
|
467 |
$html = preg_replace('/<\/form>/i',
|
481 |
else
|
482 |
$css = '' ;
|
483 |
|
484 |
+
// Tidy up Javascript to ensure it isn't affected by 'the_content' filters
|
485 |
+
$patterns = array('/[\r\n]+/', '/ +/') ;
|
486 |
+
$replacements = array('', ' ') ;
|
487 |
+
$css = preg_replace($patterns, $replacements, $css) . PHP_EOL ;
|
488 |
+
//$css = preg_replace('/[\r\n]+/', '', $css) . PHP_EOL ;
|
489 |
+
|
490 |
+
|
491 |
// Output Javscript for form validation, make sure any class prefix is included
|
492 |
+
// Need to fix the name arguments for checkboxes so PHP will pass them as an array correctly.
|
493 |
+
// This jQuery script reformats the checkboxes so that Googles Python script will read them.
|
494 |
+
|
495 |
$js = sprintf('
|
496 |
<script type="text/javascript">
|
497 |
jQuery(document).ready(function($) {
|
|
|
|
|
498 |
$("div.%sss-form-container input:checkbox").each(function(index) {
|
499 |
this.name = this.name + \'[]\';
|
500 |
});
|
524 |
</script>
|
525 |
' ;
|
526 |
|
527 |
+
// Tidy up Javascript to ensure it isn't affected by 'the_content' filters
|
528 |
+
//$js = preg_replace('/[\r\n]+/', '', $js) . PHP_EOL ;
|
529 |
+
$js = preg_replace($patterns, $replacements, $js) . PHP_EOL ;
|
530 |
+
|
531 |
// Send email?
|
532 |
if ($posted && is_null($action) && $email)
|
533 |
{
|
534 |
+
wpGForm::SendConfirmationEmail($wpgform_options['email_format'], $sendto) ;
|
535 |
}
|
536 |
|
537 |
// Check browser compatibility? The jQuery used by this plugin may
|
566 |
*/
|
567 |
function GetPageURL()
|
568 |
{
|
569 |
+
global $pagenow ;
|
570 |
$pageURL = 'http' ;
|
571 |
|
572 |
if ($_SERVER["HTTPS"] == "on") $pageURL .= 's' ;
|
601 |
'title' => 'on', // Remove the H1 element(s) from the Form
|
602 |
'maph1h2' => 'off', // Map H1 element(s) on the form to H2 element(s)
|
603 |
'email' => 'off', // Send an email confirmation to blog admin on submission
|
604 |
+
'sendto' => null, // Send an email confirmation to a specific address on submission
|
605 |
'style' => WPGFORM_CONFIRM_REDIRECT // How to present the custom confirmation after submit
|
606 |
), $atts) ;
|
607 |
|
616 |
*
|
617 |
* @param string $action - action to take, register or unregister
|
618 |
*/
|
619 |
+
function SendConfirmationEmail($mode = WPGFORM_EMAIL_FORMAT_HTML, $sendto = false)
|
620 |
{
|
621 |
+
if ($sendto === false || $sendto === null) $sendto = get_bloginfo('admin_email') ;
|
622 |
+
|
623 |
if ($mode == WPGFORM_EMAIL_FORMAT_HTML)
|
624 |
{
|
625 |
$headers = 'MIME-Version: 1.0' . PHP_EOL ;
|
631 |
}
|
632 |
|
633 |
$headers .= sprintf("From: %s <%s>",
|
634 |
+
get_bloginfo('name'), $sendto) . PHP_EOL ;
|
635 |
|
636 |
+
$headers .= sprintf("Cc: %s", $sendto) . PHP_EOL ;
|
637 |
$headers .= sprintf("Bcc: %s", get_bloginfo('admin_email')) . PHP_EOL ;
|
638 |
+
$headers .= sprintf("Reply-To: %s", $sendto) . PHP_EOL ;
|
639 |
$headers .= sprintf("X-Mailer: PHP/%s", phpversion()) ;
|
640 |
|
641 |
if ($mode == WPGFORM_EMAIL_FORMAT_HTML)
|
647 |
</head>
|
648 |
<body>
|
649 |
<p>
|
650 |
+
FYI -
|
651 |
</p>
|
652 |
<p>
|
653 |
A form was submitted on your web site.
|
672 |
}
|
673 |
else
|
674 |
{
|
675 |
+
$plain = 'FYI -' . PHP_EOL . PHP_EOL ;
|
676 |
$plain .= 'A form was submitted on your web site:' . PHP_EOL . PHP_EOL ;
|
677 |
$plain .= 'URL: %s' . PHP_EOL . 'Date: %s' . PHP_EOL . 'Time: %s' . PHP_EOL . PHP_EOL ;
|
678 |
$plain .= 'Thank you,' . PHP_EOL . PHP_EOL . '%s' . PHP_EOL ;
|
681 |
date('Y-m-d'), date('H:i'), get_option('blogname')) ;
|
682 |
}
|
683 |
|
684 |
+
$to = sprintf('%s wpGForm Contact <%s>, %s Admin<%s>',
|
685 |
+
get_option('blogname'), $sendto,
|
686 |
get_option('blogname'), get_option('admin_email')) ;
|
687 |
|
688 |
$subject = sprintf('Form Submission from %s', get_option('blogname')) ;
|