Google Forms - Version 0.45

Version Description

No known upgrade issues.

Download this release

Release Info

Developer mpwalsh8
Plugin Icon wp plugin Google Forms
Version 0.45
Comparing to
See all releases

Code changes from version 0.44 to 0.45

Files changed (4) hide show
  1. index.php +4 -2
  2. readme.txt +5 -1
  3. wpgform-core.php +38 -22
  4. wpgform-options.php +1 -1
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.44
8
- * Build: 0.44.$WCREV$
9
  * Last Modified: $WCDATE$
10
  * Author: Mike Walsh
11
  * Author URI: http://www.michaelwalsh.org
@@ -25,6 +25,8 @@
25
  *
26
  */
27
 
 
 
28
  require_once('wpgform-core.php') ;
29
 
30
  // Use the register_activation_hook to set default values
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.45
8
+ * Build: 0.45.$WCREV$
9
  * Last Modified: $WCDATE$
10
  * Author: Mike Walsh
11
  * Author URI: http://www.michaelwalsh.org
25
  *
26
  */
27
 
28
+ define('WPGFORM_VERSION', '0.45') ;
29
+
30
  require_once('wpgform-core.php') ;
31
 
32
  // Use the register_activation_hook to set default values
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.4.2
7
- Stable tag: 0.44
8
 
9
  Embeds a published, public Google Form in a WordPress post, page, or widget.
10
 
@@ -204,6 +204,10 @@ No known upgrade issues.
204
 
205
  == Changelog ==
206
 
 
 
 
 
207
  = Version 0.44 =
208
  * Fixed bug preventing options which are enabled by default from being turned off.
209
 
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.45
8
 
9
  Embeds a published, public Google Form in a WordPress post, page, or widget.
10
 
204
 
205
  == Changelog ==
206
 
207
+ = Version 0.45 =
208
+ * Updated load of jQuery UI Tabs CSS to latest version.
209
+ * Moved generated jQuery script from part of the form to the WordPress wp_footer action.
210
+
211
  = Version 0.44 =
212
  * Fixed bug preventing options which are enabled by default from being turned off.
213
 
wpgform-core.php CHANGED
@@ -56,6 +56,7 @@ function wpgform_init()
56
 
57
  add_filter('the_content', 'wpautop');
58
  add_action('template_redirect', 'wpgform_head') ;
 
59
  }
60
 
61
  add_action('init', array('wpGForm', 'ProcessGForm')) ;
@@ -200,6 +201,11 @@ class wpGForm
200
  */
201
  static $wpgform_js = false ;
202
 
 
 
 
 
 
203
  /**
204
  * Property to indicate CSS output state
205
  */
@@ -586,19 +592,22 @@ class wpGForm
586
  // Need to fix the name arguments for checkboxes so PHP will pass them as an array correctly.
587
  // This jQuery script reformats the checkboxes so that Googles Python script will read them.
588
 
589
- $js = '
590
  <script type="text/javascript">
 
591
  jQuery(document).ready(function($) {
592
- ' ;
593
 
594
  // Insert breaks between labels and input fields?
595
  if ($br) $js .= '
596
- $("#ss-form textarea").before("<br/>");
597
- $("#ss-form input[type=text]").before("<br/>");
 
598
  ' ;
599
 
600
  // Did short code specify a CSS prefix?
601
  if (!is_null($prefix)) $js .= sprintf('
 
602
  $("div.ss-form-container [class]").each(function(i, el) {
603
  var c = $(this).attr("class").split(" ");
604
  for (var i = 0; i < c.length; ++i) {
@@ -610,14 +619,14 @@ jQuery(document).ready(function($) {
610
 
611
  // Hide Google Legal Stuff?
612
  if (!(bool)$legal) $js .= sprintf('
 
613
  $("div.%sss-legal").hide();
614
  ', $prefix) ;
615
 
616
  // Is CAPTCHA enabled?
617
  if ($captcha) $js .= sprintf('
618
- $.validator.methods.equal = function(value, element, param) {
619
- return value == param;
620
- };
621
  $("#ss-form").append(\'%s\');
622
  if ($("#ss-form input[type=submit][name=submit]").length) {
623
  $("div.gform-captcha").show();
@@ -640,28 +649,25 @@ jQuery(document).ready(function($) {
640
 
641
  // Include jQuery validation?
642
  if ($validation) $js .= sprintf('
 
643
  $("div > .ss-item-required textarea").addClass("gform-required");
644
  $("div > .ss-item-required input:not(.ss-q-other").addClass("gform-required");
645
  $("div > .%sss-item-required textarea").addClass("gform-required");
646
  $("div > .%sss-item-required input:not(.%sss-q-other").addClass("gform-required");
647
-
648
- $.validator.addClassRules("gform-required", {
649
- required: true
650
- });
651
-
652
- $("#ss-form").validate({
653
- errorClass: "gform-error"
654
- }) ;
655
  ', $prefix, $prefix, $prefix) ;
656
 
657
  // Always include the jQuery to clean up the checkboxes
658
  $js .= sprintf('
 
659
  $("div.%sss-form-container input:checkbox").each(function(index) {
660
  this.name = this.name + \'[]\';
661
  });
662
  ', $prefix) ;
663
  // Before closing the <script> tag, is the form read only?
664
  if ($readonly) $js .= sprintf('
 
665
  $("div.%sss-form-container :input").attr("disabled", true);
666
  ', $prefix) ;
667
 
@@ -697,7 +703,7 @@ jQuery(document).ready(function($) {
697
  ' ;
698
 
699
  // Tidy up Javascript to ensure it isn't affected by 'the_content' filters
700
- $js = preg_replace($patterns, $replacements, $js) . PHP_EOL ;
701
 
702
  // Send email?
703
  if (self::$posted && is_null($action) && $email)
@@ -751,8 +757,9 @@ jQuery(document).ready(function($) {
751
  if (is_null(self::$wpgform_submitted_form_id) ||
752
  self::$wpgform_submitted_form_id == self::$wpgform_form_id - 1)
753
  {
754
- $onetime_html .= $js ;
755
  self::$wpgform_js = true ;
 
756
  }
757
  }
758
 
@@ -1007,11 +1014,6 @@ jQuery(document).ready(function($) {
1007
  }
1008
 
1009
  $to = sprintf('%s wpGForm Contact <%s>', get_option('blogname'), $sendto) ;
1010
-
1011
- //$to = sprintf('%s wpGForm Contact <%s>, %s Admin<%s>',
1012
- // get_option('blogname'), $sendto,
1013
- // get_option('blogname'), get_option('admin_email')) ;
1014
-
1015
  $subject = sprintf('Form Submission from %s', get_option('blogname')) ;
1016
 
1017
  if (WPGFORM_DEBUG)
@@ -1021,6 +1023,7 @@ jQuery(document).ready(function($) {
1021
 
1022
  return $status ;
1023
  }
 
1024
  }
1025
 
1026
  /**
@@ -1049,4 +1052,17 @@ function wpgform_head()
1049
  array('jquery'), false, true) ;
1050
  wp_enqueue_script('jquery-validate') ;
1051
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
1052
  ?>
56
 
57
  add_filter('the_content', 'wpautop');
58
  add_action('template_redirect', 'wpgform_head') ;
59
+ add_action('wp_footer', 'wpgform_footer') ;
60
  }
61
 
62
  add_action('init', array('wpGForm', 'ProcessGForm')) ;
201
  */
202
  static $wpgform_js = false ;
203
 
204
+ /**
205
+ * Property to store Javascript output in footer
206
+ */
207
+ static $wpgform_footer_js = '' ;
208
+
209
  /**
210
  * Property to indicate CSS output state
211
  */
592
  // Need to fix the name arguments for checkboxes so PHP will pass them as an array correctly.
593
  // This jQuery script reformats the checkboxes so that Googles Python script will read them.
594
 
595
+ $js = sprintf('
596
  <script type="text/javascript">
597
+ // WordPress Google Form v%s jQuery script
598
  jQuery(document).ready(function($) {
599
+ ', WPGFORM_VERSION) ;
600
 
601
  // Insert breaks between labels and input fields?
602
  if ($br) $js .= '
603
+ // Insert br elements before input and textarea boxes
604
+ $("#ss-form textarea").before("<br/>");
605
+ $("#ss-form input[type=text]").before("<br/>");
606
  ' ;
607
 
608
  // Did short code specify a CSS prefix?
609
  if (!is_null($prefix)) $js .= sprintf('
610
+ // Manipulate CSS classes to account for CSS prefix
611
  $("div.ss-form-container [class]").each(function(i, el) {
612
  var c = $(this).attr("class").split(" ");
613
  for (var i = 0; i < c.length; ++i) {
619
 
620
  // Hide Google Legal Stuff?
621
  if (!(bool)$legal) $js .= sprintf('
622
+ // Hide Google Legal content
623
  $("div.%sss-legal").hide();
624
  ', $prefix) ;
625
 
626
  // Is CAPTCHA enabled?
627
  if ($captcha) $js .= sprintf('
628
+ // Construct CAPTCHA
629
+ $.validator.methods.equal = function(value, element, param) { return value == param; };
 
630
  $("#ss-form").append(\'%s\');
631
  if ($("#ss-form input[type=submit][name=submit]").length) {
632
  $("div.gform-captcha").show();
649
 
650
  // Include jQuery validation?
651
  if ($validation) $js .= sprintf('
652
+ // jQuery inline validation
653
  $("div > .ss-item-required textarea").addClass("gform-required");
654
  $("div > .ss-item-required input:not(.ss-q-other").addClass("gform-required");
655
  $("div > .%sss-item-required textarea").addClass("gform-required");
656
  $("div > .%sss-item-required input:not(.%sss-q-other").addClass("gform-required");
657
+ $.validator.addClassRules("gform-required", { required: true });
658
+ $("#ss-form").validate({ errorClass: "gform-error" }) ;
 
 
 
 
 
 
659
  ', $prefix, $prefix, $prefix) ;
660
 
661
  // Always include the jQuery to clean up the checkboxes
662
  $js .= sprintf('
663
+ // Fix checkboxes to work with Google Python
664
  $("div.%sss-form-container input:checkbox").each(function(index) {
665
  this.name = this.name + \'[]\';
666
  });
667
  ', $prefix) ;
668
  // Before closing the <script> tag, is the form read only?
669
  if ($readonly) $js .= sprintf('
670
+ // Put form in read-only mode
671
  $("div.%sss-form-container :input").attr("disabled", true);
672
  ', $prefix) ;
673
 
703
  ' ;
704
 
705
  // Tidy up Javascript to ensure it isn't affected by 'the_content' filters
706
+ //$js = preg_replace($patterns, $replacements, $js) . PHP_EOL ;
707
 
708
  // Send email?
709
  if (self::$posted && is_null($action) && $email)
757
  if (is_null(self::$wpgform_submitted_form_id) ||
758
  self::$wpgform_submitted_form_id == self::$wpgform_form_id - 1)
759
  {
760
+ //$onetime_html .= $js ;
761
  self::$wpgform_js = true ;
762
+ self::$wpgform_footer_js = $js ;
763
  }
764
  }
765
 
1014
  }
1015
 
1016
  $to = sprintf('%s wpGForm Contact <%s>', get_option('blogname'), $sendto) ;
 
 
 
 
 
1017
  $subject = sprintf('Form Submission from %s', get_option('blogname')) ;
1018
 
1019
  if (WPGFORM_DEBUG)
1023
 
1024
  return $status ;
1025
  }
1026
+
1027
  }
1028
 
1029
  /**
1052
  array('jquery'), false, true) ;
1053
  wp_enqueue_script('jquery-validate') ;
1054
  }
1055
+
1056
+ /**
1057
+ * wpgform_head()
1058
+ *
1059
+ * WordPress footer actions
1060
+ *
1061
+ */
1062
+ function wpgform_footer()
1063
+ {
1064
+ // Output the generated jQuery script as part of the footer
1065
+
1066
+ print wpGForm::$wpgform_footer_js ;
1067
+ }
1068
  ?>
wpgform-options.php CHANGED
@@ -67,7 +67,7 @@ function wpgform_options_print_styles()
67
  // Load them from Google - should not be an issue since
68
  // this plugin is all about consuming Google content!
69
 
70
- wp_enqueue_style('xtra-jquery-ui-css', 'http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css') ;
71
  }
72
 
73
  /**
67
  // Load them from Google - should not be an issue since
68
  // this plugin is all about consuming Google content!
69
 
70
+ wp_enqueue_style('xtra-jquery-ui-css', 'http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.24/themes/base/jquery-ui.css') ;
71
  }
72
 
73
  /**